feat:个人喜好统计
This commit is contained in:
1 parent
4be6f4c03e
commit
f0412a73cf
8 files changed
+126
-8
No files matched your search
+4
-3
@@ -1,11 +1,9 @@
|
||||
package com.bsd.pjcloud.hard.api.dto.order.app;
|
||||
|
||||
import com.bsd.pjcloud.hard.api.constant.total.DateRangeTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -14,8 +12,11 @@ import java.util.List;
|
||||
@Data
|
||||
public class HardAppProductByCanteenDto {
|
||||
|
||||
@Schema(description = "用户Id")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "食堂id")
|
||||
private List<String> canteenIdList;
|
||||
private List<Long> canteenIdList;
|
||||
|
||||
@Schema(description = "用餐时间段")
|
||||
private String hourType;
|
||||
|
||||
+3
@@ -13,6 +13,9 @@ import java.util.List;
|
||||
@Data
|
||||
public class HardAppProductByClassifyDto {
|
||||
|
||||
@Schema(description = "用户Id")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "食堂id")
|
||||
private List<String> canteenIdList;
|
||||
|
||||
|
||||
+8
@@ -49,6 +49,10 @@ public class HardCanteenTotalController {
|
||||
@Operation(summary = "菜品销量按照分类查询", description = "菜品销量按照分类查询")
|
||||
@PostMapping("/app/product-by-classify")
|
||||
public R<List<HardAppProductByClassifyVo>> productByClassify(@RequestBody HardAppProductByClassifyDto dto) {
|
||||
PjcloudUser user = SecurityUtils.getUser();
|
||||
if (ObjectUtil.isNotEmpty(user)) {
|
||||
dto.setUserId(user.getId());
|
||||
}
|
||||
return R.ok(canteenTotalService.productByClassify(dto));
|
||||
}
|
||||
|
||||
@@ -59,6 +63,10 @@ public class HardCanteenTotalController {
|
||||
@Operation(summary = "近一周各个食堂菜品购买统计", description = "近一周各个食堂菜品购买统计")
|
||||
@PostMapping("/app/product-by-canteen")
|
||||
public R<List<Map<String, List<HardAppProductByCanteenVo>>>> productByCanteen(@RequestBody HardAppProductByCanteenDto dto) {
|
||||
PjcloudUser user = SecurityUtils.getUser();
|
||||
if (ObjectUtil.isNotEmpty(user)) {
|
||||
dto.setUserId(user.getId());
|
||||
}
|
||||
return R.ok(canteenTotalService.productByCanteen(dto));
|
||||
}
|
||||
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package com.bsd.pjcloud.hard.controller.sync;
|
||||
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.idempotent.annotation.Idempotent;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.common.security.service.PjcloudUser;
|
||||
import com.bsd.pjcloud.common.security.util.SecurityUtils;
|
||||
import com.bsd.pjcloud.hard.service.HardSyncService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 设备同步
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/hard-sync")
|
||||
@Tag(description = "hard-sync", name = "设备同步")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class HardSyncController {
|
||||
|
||||
private final HardSyncService hardSyncService;
|
||||
|
||||
@Operation(summary = "同步超市分类商品和同步", description = "同步超市分类商品和同步")
|
||||
@SysLog("同步超市分类商品和同步")
|
||||
@Idempotent(expireTime = 3, info = "正在同步中,请勿重复操作")
|
||||
@GetMapping("/sync-supermarket")
|
||||
public R syncSupermarket() {
|
||||
PjcloudUser user = SecurityUtils.getUser();
|
||||
hardSyncService.syncSupermarket(user);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.bsd.pjcloud.hard.service;
|
||||
|
||||
import com.bsd.pjcloud.common.security.service.PjcloudUser;
|
||||
|
||||
public interface HardSyncService {
|
||||
|
||||
/**
|
||||
* 同步超市分类商品和同步
|
||||
*/
|
||||
void syncSupermarket(PjcloudUser user);
|
||||
|
||||
}
|
||||
+12
-5
@@ -9,6 +9,7 @@ import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
|
||||
import com.bsd.pjcloud.canteen.api.feign.RemoteCanteenCategoryService;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenCategoryEntity;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.MerchantTypeEnum;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.total.DateRangeTypeEnum;
|
||||
@@ -86,6 +87,14 @@ public class HardCanteenTotalServiceImpl implements HardCanteenTotalService {
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, List<HardAppProductByCanteenVo>>> productByCanteen(HardAppProductByCanteenDto dto) {
|
||||
// 查询自营食堂并且在移动端显示的
|
||||
List<MchManageVo> canteenList = remoteMchService.getByTypes(List.of(MerchantTypeEnum.CANTEEN.getType())).getData();
|
||||
if (ObjectUtil.isEmpty(canteenList)) return null;
|
||||
canteenList = canteenList.stream().filter(v -> ObjectUtil.equals(v.getVisibleMobile(), YesNoEnum.YES.getCode())).toList();
|
||||
if (ObjectUtil.isNotEmpty(canteenList)) {
|
||||
List<Long> canteenIdList = canteenList.stream().map(MchManageVo::getId).toList();
|
||||
dto.setCanteenIdList(canteenIdList);
|
||||
}
|
||||
dto.setPayTimeList(new LocalDate[]{LocalDate.now().minusWeeks(1), LocalDate.now()});
|
||||
// 查询近一周的时间
|
||||
List<HardAppProductByCanteenVo> dateList = new LinkedList<>();
|
||||
@@ -99,10 +108,8 @@ public class HardCanteenTotalServiceImpl implements HardCanteenTotalService {
|
||||
}
|
||||
|
||||
// 查询自营食堂
|
||||
List<MchManageVo> mchList = remoteMchService.getByTypes(List.of(MerchantTypeEnum.CANTEEN.getType())).getData();
|
||||
if (ObjectUtil.isEmpty(mchList)) return null;
|
||||
List<Map<String, List<HardAppProductByCanteenVo>>> result = new ArrayList<>();
|
||||
for (MchManageVo vo : mchList) {
|
||||
for (MchManageVo vo : canteenList) {
|
||||
result.add(Map.of(vo.getName(), dateList));
|
||||
}
|
||||
|
||||
@@ -112,8 +119,8 @@ public class HardCanteenTotalServiceImpl implements HardCanteenTotalService {
|
||||
for (Map<String, List<HardAppProductByCanteenVo>> map : result) {
|
||||
for (Map.Entry<String, List<HardAppProductByCanteenVo>> entry : map.entrySet()) {
|
||||
String canteenName = entry.getKey();
|
||||
List<HardAppProductByCanteenVo> canteenList = entry.getValue();
|
||||
for (HardAppProductByCanteenVo vo : canteenList) {
|
||||
List<HardAppProductByCanteenVo> currentCanteenList = entry.getValue();
|
||||
for (HardAppProductByCanteenVo vo : currentCanteenList) {
|
||||
dateList.stream().filter(item -> ObjectUtil.equals(item.getCanteenName(), canteenName) && ObjectUtil.equals(item.getTime(), vo.getTime())).findFirst().ifPresent(target -> {
|
||||
target.setCanteenId(vo.getCanteenId());
|
||||
target.setCanteenName(canteenName);
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package com.bsd.pjcloud.hard.service.impl.sync;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.MerchantTypeEnum;
|
||||
import com.bsd.pjcloud.common.security.service.PjcloudUser;
|
||||
import com.bsd.pjcloud.hard.service.HardSyncService;
|
||||
import com.bsd.pjcloud.mqtt.api.feign.RemoteMqttEventService;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteMchService;
|
||||
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class HardSyncServiceImpl implements HardSyncService {
|
||||
|
||||
private final RemoteMchService remoteMchService;
|
||||
private final RemoteMqttEventService mqttEventService;
|
||||
|
||||
/**
|
||||
* 同步超市分类商品和同步
|
||||
*/
|
||||
@Override
|
||||
public void syncSupermarket(PjcloudUser user) {
|
||||
if (ObjectUtil.isEmpty(user)) throw new RuntimeException("当前登录用户错误");
|
||||
Long deptId = user.getDeptId();
|
||||
// 查询该用户属于的超市
|
||||
MchManageVo targetMch = remoteMchService.getFirstMchByDeptId(deptId, MerchantTypeEnum.CANTEEN).getData();
|
||||
if (ObjectUtil.isEmpty(targetMch) || ObjectUtil.notEqual(targetMch.getTypes(), MerchantTypeEnum.CANTEEN.getType())) {
|
||||
throw new RuntimeException("您不是超市用户,无法操作");
|
||||
}
|
||||
mqttEventService.sendSupermarketClassifyChangeMsg(deptId);
|
||||
mqttEventService.sendSupermarketProductChangeMsg(deptId);
|
||||
}
|
||||
|
||||
}
|
||||
+6
@@ -300,6 +300,9 @@
|
||||
left join pjcloudx_canteen.canteen_spu s on a.product_id = s.id
|
||||
<where>
|
||||
a.del_flag = '0'
|
||||
<if test="dto.userId != null and dto.userId != '' ">
|
||||
and o.user_id = #{dto.userId}
|
||||
</if>
|
||||
<if test="dto.hourType != null and dto.hourType != '' ">
|
||||
and o.hour_type = #{dto.hourType}
|
||||
</if>
|
||||
@@ -332,6 +335,9 @@
|
||||
<where>
|
||||
a.del_flag = '0'
|
||||
and o.pay_time is not null
|
||||
<if test="dto.userId != null and dto.userId != '' ">
|
||||
and o.user_id = #{dto.userId}
|
||||
</if>
|
||||
<if test="dto.canteenIdList != null and dto.canteenIdList.size() != 0">
|
||||
and o.merchant_id in
|
||||
<foreach collection="dto.canteenIdList" item="v" open="(" close=")" separator=",">
|
||||
|
||||
Reference in new issue
Block a user