Showing
17 changed files
with
436 additions
and
56 deletions
| ... | @@ -9,6 +9,7 @@ import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderServi | ... | @@ -9,6 +9,7 @@ import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderServi |
| 9 | import com.infoloop.tianting.clientcustomerservice.ClientCustomerServiceRpcGrpc; | 9 | import com.infoloop.tianting.clientcustomerservice.ClientCustomerServiceRpcGrpc; |
| 10 | import com.infoloop.tianting.clientinventoryservice.TiantingClientInventoryServiceRpcGrpc; | 10 | import com.infoloop.tianting.clientinventoryservice.TiantingClientInventoryServiceRpcGrpc; |
| 11 | import com.infoloop.tianting.deliveryruleservice.TiantingDeliveryRuleServiceRpcGrpc; | 11 | import com.infoloop.tianting.deliveryruleservice.TiantingDeliveryRuleServiceRpcGrpc; |
| 12 | +import com.infoloop.tianting.enterpriseresourcetagservice.EnterpriseResourceTagServiceRpcGrpc; | ||
| 12 | import com.infoloop.tianting.menuservice.MenuServiceRpcGrpc; | 13 | import com.infoloop.tianting.menuservice.MenuServiceRpcGrpc; |
| 13 | import com.infoloop.tianting.setmealscheduleservice.SetMealScheduleServiceRpcGrpc; | 14 | import com.infoloop.tianting.setmealscheduleservice.SetMealScheduleServiceRpcGrpc; |
| 14 | import com.tianting.infoloop.grpc.exampleservice.ExampleServiceRpcGrpc; | 15 | import com.tianting.infoloop.grpc.exampleservice.ExampleServiceRpcGrpc; |
| ... | @@ -39,6 +40,9 @@ import static com.infoloop.tianting.constant.ConfigConstants.CLIENT_INVENTORY_SE | ... | @@ -39,6 +40,9 @@ import static com.infoloop.tianting.constant.ConfigConstants.CLIENT_INVENTORY_SE |
| 39 | import static com.infoloop.tianting.constant.ConfigConstants.DELIVERY_SERVICE_CHANNEL; | 40 | import static com.infoloop.tianting.constant.ConfigConstants.DELIVERY_SERVICE_CHANNEL; |
| 40 | import static com.infoloop.tianting.constant.ConfigConstants.DELIVERY_SERVICE_RPC_PORT; | 41 | import static com.infoloop.tianting.constant.ConfigConstants.DELIVERY_SERVICE_RPC_PORT; |
| 41 | import static com.infoloop.tianting.constant.ConfigConstants.DELIVERY_SERVICE_RPC_URL; | 42 | import static com.infoloop.tianting.constant.ConfigConstants.DELIVERY_SERVICE_RPC_URL; |
| 43 | +import static com.infoloop.tianting.constant.ConfigConstants.ENTERPRISE_RESOURCE_SERVICE_CHANNEL; | ||
| 44 | +import static com.infoloop.tianting.constant.ConfigConstants.ENTERPRISE_RESOURCE_SERVICE_RPC_PORT; | ||
| 45 | +import static com.infoloop.tianting.constant.ConfigConstants.ENTERPRISE_RESOURCE_SERVICE_RPC_URL; | ||
| 42 | import static com.infoloop.tianting.constant.ConfigConstants.EXAMPLE_SERVICE_CHANNEL; | 46 | import static com.infoloop.tianting.constant.ConfigConstants.EXAMPLE_SERVICE_CHANNEL; |
| 43 | import static com.infoloop.tianting.constant.ConfigConstants.EXAMPLE_SERVICE_RPC_PORT; | 47 | import static com.infoloop.tianting.constant.ConfigConstants.EXAMPLE_SERVICE_RPC_PORT; |
| 44 | import static com.infoloop.tianting.constant.ConfigConstants.EXAMPLE_SERVICE_RPC_URL; | 48 | import static com.infoloop.tianting.constant.ConfigConstants.EXAMPLE_SERVICE_RPC_URL; |
| ... | @@ -256,6 +260,23 @@ public class GrpcConfig { | ... | @@ -256,6 +260,23 @@ public class GrpcConfig { |
| 256 | return WOperatorServiceProtoRpcGrpc.newBlockingStub(channel); | 260 | return WOperatorServiceProtoRpcGrpc.newBlockingStub(channel); |
| 257 | } | 261 | } |
| 258 | 262 | ||
| 263 | + @Bean(ENTERPRISE_RESOURCE_SERVICE_CHANNEL) | ||
| 264 | + public ManagedChannel enterpriseResourceServiceChannel(@Value(ENTERPRISE_RESOURCE_SERVICE_RPC_URL) final String url, | ||
| 265 | + @Value(ENTERPRISE_RESOURCE_SERVICE_RPC_PORT) final int port, | ||
| 266 | + @Autowired final ClientInterceptor clientInterceptor) { | ||
| 267 | + return NettyChannelBuilder.forAddress(url, port) | ||
| 268 | + .idleTimeout(DEFAULT_TIMEOUT_DAYS, TimeUnit.DAYS) | ||
| 269 | + .intercept(clientInterceptor) | ||
| 270 | + .usePlaintext() | ||
| 271 | + .maxInboundMessageSize(Integer.MAX_VALUE) | ||
| 272 | + .build(); | ||
| 273 | + } | ||
| 274 | + | ||
| 275 | + @Bean | ||
| 276 | + public EnterpriseResourceTagServiceRpcGrpc.EnterpriseResourceTagServiceRpcBlockingStub enterpriseResourceRpcBlockingStub(@Autowired @Qualifier(ENTERPRISE_RESOURCE_SERVICE_CHANNEL) final ManagedChannel channel) { | ||
| 277 | + return EnterpriseResourceTagServiceRpcGrpc.newBlockingStub(channel); | ||
| 278 | + } | ||
| 279 | + | ||
| 259 | @Bean(MEIZHONGYIHE_SERVICE_CHANNEL) | 280 | @Bean(MEIZHONGYIHE_SERVICE_CHANNEL) |
| 260 | public ManagedChannel meiZhongYiHeServiceChannel(@Value(MEIZHONGYIHE_SERVICE_RPC_URL) final String url, | 281 | public ManagedChannel meiZhongYiHeServiceChannel(@Value(MEIZHONGYIHE_SERVICE_RPC_URL) final String url, |
| 261 | @Value(MEIZHONGYIHE_SERVICE_RPC_PORT) final int port, | 282 | @Value(MEIZHONGYIHE_SERVICE_RPC_PORT) final int port, | ... | ... |
| 1 | package com.infoloop.tianting.config; | 1 | package com.infoloop.tianting.config; |
| 2 | 2 | ||
| 3 | +import static springfox.documentation.builders.RequestHandlerSelectors.basePackage; | ||
| 4 | + | ||
| 3 | import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; | 5 | import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; |
| 4 | import com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver; | 6 | import com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver; |
| 5 | import com.infoloop.tianting.constant.CommonConstants; | 7 | import com.infoloop.tianting.constant.CommonConstants; |
| ... | @@ -59,7 +61,7 @@ public class SwaggerConfig { | ... | @@ -59,7 +61,7 @@ public class SwaggerConfig { |
| 59 | .apiInfo(apiInfo()) | 61 | .apiInfo(apiInfo()) |
| 60 | .groupName(groupName) | 62 | .groupName(groupName) |
| 61 | .select() | 63 | .select() |
| 62 | - .apis(RequestHandlerSelectors.basePackage("com.infoloop.tianting.controller")) | 64 | + .apis(RequestHandlerSelectors.basePackage("com.infoloop.tianting.controller").or(RequestHandlerSelectors.basePackage("com.infoloop.tianting.streamController"))) |
| 63 | .paths(PathSelectors.any()) | 65 | .paths(PathSelectors.any()) |
| 64 | .build() | 66 | .build() |
| 65 | //赋予插件体系 | 67 | //赋予插件体系 | ... | ... |
| ... | @@ -68,6 +68,10 @@ public interface ConfigConstants { | ... | @@ -68,6 +68,10 @@ public interface ConfigConstants { |
| 68 | String WOPERATOR_SERVICE_RPC_PORT = "${grpc.woperator-service.port}"; | 68 | String WOPERATOR_SERVICE_RPC_PORT = "${grpc.woperator-service.port}"; |
| 69 | String WOPERATOR_SERVICE_CHANNEL = "woperator-service-channel"; | 69 | String WOPERATOR_SERVICE_CHANNEL = "woperator-service-channel"; |
| 70 | 70 | ||
| 71 | + String ENTERPRISE_RESOURCE_SERVICE_RPC_URL = "${grpc.enterprise-resource-service.url}"; | ||
| 72 | + String ENTERPRISE_RESOURCE_SERVICE_RPC_PORT = "${grpc.enterprise-resource-service.port}"; | ||
| 73 | + String ENTERPRISE_RESOURCE_SERVICE_CHANNEL = "enterprise-resource-service-channel"; | ||
| 74 | + | ||
| 71 | String MEIZHONGYIHE_SERVICE_RPC_URL = "${grpc.meizhongyihe-service.url}"; | 75 | String MEIZHONGYIHE_SERVICE_RPC_URL = "${grpc.meizhongyihe-service.url}"; |
| 72 | String MEIZHONGYIHE_SERVICE_RPC_PORT = "${grpc.meizhongyihe-service.port}"; | 76 | String MEIZHONGYIHE_SERVICE_RPC_PORT = "${grpc.meizhongyihe-service.port}"; |
| 73 | String MEIZHONGYIHE_SERVICE_CHANNEL = "meizhongyihe-service-channel"; | 77 | String MEIZHONGYIHE_SERVICE_CHANNEL = "meizhongyihe-service-channel"; | ... | ... |
| 1 | package com.infoloop.tianting.controller; | 1 | package com.infoloop.tianting.controller; |
| 2 | 2 | ||
| 3 | import com.github.xiaoymin.knife4j.annotations.ApiSupport; | 3 | import com.github.xiaoymin.knife4j.annotations.ApiSupport; |
| 4 | +import com.infoloop.tianting.model.dto.ClientLabelDTO; | ||
| 5 | +import com.infoloop.tianting.model.dto.ClientLabelDTO.LabelDto; | ||
| 6 | +import com.infoloop.tianting.model.dto.KdsDTO; | ||
| 7 | +import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderLocationDto; | ||
| 8 | +import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderSkuDto; | ||
| 9 | +import com.infoloop.tianting.service.KdsService; | ||
| 4 | import io.swagger.annotations.Api; | 10 | import io.swagger.annotations.Api; |
| 11 | +import io.swagger.annotations.ApiOperation; | ||
| 12 | +import java.util.List; | ||
| 13 | +import javax.validation.Valid; | ||
| 5 | import lombok.RequiredArgsConstructor; | 14 | import lombok.RequiredArgsConstructor; |
| 6 | import lombok.extern.slf4j.Slf4j; | 15 | import lombok.extern.slf4j.Slf4j; |
| 7 | import org.springframework.beans.factory.annotation.Autowired; | 16 | import org.springframework.beans.factory.annotation.Autowired; |
| 17 | +import org.springframework.http.HttpStatus; | ||
| 8 | import org.springframework.validation.annotation.Validated; | 18 | import org.springframework.validation.annotation.Validated; |
| 19 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 20 | +import org.springframework.web.bind.annotation.RequestBody; | ||
| 21 | +import org.springframework.web.bind.annotation.ResponseStatus; | ||
| 9 | import org.springframework.web.bind.annotation.RestController; | 22 | import org.springframework.web.bind.annotation.RestController; |
| 10 | 23 | ||
| 11 | @Api(tags = "KDS") | 24 | @Api(tags = "KDS") |
| ... | @@ -16,5 +29,20 @@ import org.springframework.web.bind.annotation.RestController; | ... | @@ -16,5 +29,20 @@ import org.springframework.web.bind.annotation.RestController; |
| 16 | @RequiredArgsConstructor(onConstructor = @__(@Autowired)) | 29 | @RequiredArgsConstructor(onConstructor = @__(@Autowired)) |
| 17 | public class KdsController { | 30 | public class KdsController { |
| 18 | 31 | ||
| 32 | + private final KdsService kdsService; | ||
| 33 | + | ||
| 34 | + @ApiOperation(value = "kds按照菜品获取订单明细") | ||
| 35 | + @PostMapping("/kds/orderDetails/bySku") | ||
| 36 | + @ResponseStatus(HttpStatus.OK) | ||
| 37 | + public List<KdsOrderSkuDto> getOrderDetailBySku(@Valid @RequestBody KdsDTO.KdsOrderSkuQueryDto queryDto) { | ||
| 38 | + return kdsService.getOrderDetailBySku(queryDto); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + @ApiOperation(value = "kds按照就餐点获取订单明细") | ||
| 42 | + @PostMapping("/kds/orderDetails/byLocation") | ||
| 43 | + @ResponseStatus(HttpStatus.OK) | ||
| 44 | + public List<KdsOrderLocationDto> getOrderDetailByLocation(@Valid @RequestBody KdsDTO.KdsOrderLocationQueryDto queryDto) { | ||
| 45 | + return kdsService.getOrderDetailByLocation(queryDto); | ||
| 46 | + } | ||
| 19 | 47 | ||
| 20 | } | 48 | } | ... | ... |
| ... | @@ -40,7 +40,6 @@ import org.springframework.web.bind.annotation.RestController; | ... | @@ -40,7 +40,6 @@ import org.springframework.web.bind.annotation.RestController; |
| 40 | public class OrderController { | 40 | public class OrderController { |
| 41 | private final OrderService orderService; | 41 | private final OrderService orderService; |
| 42 | 42 | ||
| 43 | - @SaIgnore | ||
| 44 | @ApiOperation(value = "根据customerId获取用户订单") | 43 | @ApiOperation(value = "根据customerId获取用户订单") |
| 45 | @GetMapping("/orders/{customerId}") | 44 | @GetMapping("/orders/{customerId}") |
| 46 | @ResponseStatus(HttpStatus.OK) | 45 | @ResponseStatus(HttpStatus.OK) |
| ... | @@ -60,7 +59,6 @@ public class OrderController { | ... | @@ -60,7 +59,6 @@ public class OrderController { |
| 60 | .build()); | 59 | .build()); |
| 61 | } | 60 | } |
| 62 | 61 | ||
| 63 | - @SaIgnore | ||
| 64 | @ApiOperation(value = "根据orderId获取订单详情") | 62 | @ApiOperation(value = "根据orderId获取订单详情") |
| 65 | @GetMapping("/orderDetails/{orderId}") | 63 | @GetMapping("/orderDetails/{orderId}") |
| 66 | @ResponseStatus(HttpStatus.OK) | 64 | @ResponseStatus(HttpStatus.OK) | ... | ... |
| 1 | +package com.infoloop.tianting.model.common; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.model.dto.OrderDbDTO.OrderCountByStatusDto; | ||
| 4 | +import io.swagger.annotations.ApiModel; | ||
| 5 | +import io.swagger.annotations.ApiModelProperty; | ||
| 6 | +import lombok.AllArgsConstructor; | ||
| 7 | +import lombok.Data; | ||
| 8 | +import lombok.EqualsAndHashCode; | ||
| 9 | +import lombok.NoArgsConstructor; | ||
| 10 | +import lombok.ToString; | ||
| 11 | + | ||
| 12 | +import java.io.Serializable; | ||
| 13 | +import java.util.List; | ||
| 14 | + | ||
| 15 | +@EqualsAndHashCode(callSuper = true) | ||
| 16 | +@Data | ||
| 17 | +@NoArgsConstructor | ||
| 18 | +@AllArgsConstructor | ||
| 19 | +@ToString | ||
| 20 | +@ApiModel(description = "订单分页返回参数") | ||
| 21 | +public final class OrderPageResult<T> extends PageInfo implements Serializable { | ||
| 22 | + | ||
| 23 | + private static final long serialVersionUID = -6287755207385079404L; | ||
| 24 | + | ||
| 25 | + @ApiModelProperty("总条数") | ||
| 26 | + private long totalCount; | ||
| 27 | + | ||
| 28 | + @ApiModelProperty("总页数") | ||
| 29 | + private long totalPage; | ||
| 30 | + | ||
| 31 | + @ApiModelProperty("数据结果集") | ||
| 32 | + private List<T> dataList; | ||
| 33 | + | ||
| 34 | + @ApiModelProperty("不同状态的订单数量") | ||
| 35 | + private OrderCountByStatusDto countByStatus; | ||
| 36 | +} | ||
| 37 | + |
| 1 | package com.infoloop.tianting.model.dto; | 1 | package com.infoloop.tianting.model.dto; |
| 2 | 2 | ||
| 3 | +import com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum; | ||
| 4 | +import com.infoloop.tianting.clientcustomerorderservice.ServeStatusEnum; | ||
| 5 | +import com.infoloop.tianting.model.dto.OrderDbDTO.CustomerNotice; | ||
| 3 | import io.swagger.annotations.ApiModel; | 6 | import io.swagger.annotations.ApiModel; |
| 4 | import io.swagger.models.auth.In; | 7 | import io.swagger.models.auth.In; |
| 5 | import java.util.List; | 8 | import java.util.List; |
| ... | @@ -16,14 +19,29 @@ public class KdsDTO { | ... | @@ -16,14 +19,29 @@ public class KdsDTO { |
| 16 | @Builder | 19 | @Builder |
| 17 | @AllArgsConstructor | 20 | @AllArgsConstructor |
| 18 | @NoArgsConstructor | 21 | @NoArgsConstructor |
| 19 | - @ApiModel(description = "KdsOrderDto") | 22 | + @ApiModel(description = "KdsOrderSkuDetailDto") |
| 20 | - public static class KdsOrderDto { | 23 | + public static class KdsOrderSkuDetailDto { |
| 21 | private Integer orderId; | 24 | private Integer orderId; |
| 22 | private Integer orderDetailId; | 25 | private Integer orderDetailId; |
| 23 | private String tableCode; | 26 | private String tableCode; |
| 24 | private Integer count; | 27 | private Integer count; |
| 25 | private String roomNo; | 28 | private String roomNo; |
| 26 | private String remark; | 29 | private String remark; |
| 30 | + private CustomerNotice customerNotice; | ||
| 31 | + private String adjustSkuRemark; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + @Data | ||
| 35 | + @Builder | ||
| 36 | + @AllArgsConstructor | ||
| 37 | + @NoArgsConstructor | ||
| 38 | + @ApiModel(description = "KdsOrderLocationDetailDto") | ||
| 39 | + public static class KdsOrderLocationDetailDto { | ||
| 40 | + private Integer orderDetailId; | ||
| 41 | + private Integer count; | ||
| 42 | + private String showName; | ||
| 43 | + private String adjustSkuRemark; | ||
| 44 | + private ServeStatusEnum serveStatus; | ||
| 27 | } | 45 | } |
| 28 | 46 | ||
| 29 | @Data | 47 | @Data |
| ... | @@ -34,6 +52,41 @@ public class KdsDTO { | ... | @@ -34,6 +52,41 @@ public class KdsDTO { |
| 34 | public static class KdsOrderSkuDto { | 52 | public static class KdsOrderSkuDto { |
| 35 | private String showName; | 53 | private String showName; |
| 36 | private Integer totalCount; | 54 | private Integer totalCount; |
| 37 | - private List<KdsOrderDto> orderList; | 55 | + private List<KdsOrderSkuDetailDto> orderList; |
| 56 | + } | ||
| 57 | + | ||
| 58 | + @Data | ||
| 59 | + @Builder | ||
| 60 | + @AllArgsConstructor | ||
| 61 | + @NoArgsConstructor | ||
| 62 | + @ApiModel(description = "KdsOrderLocationDto") | ||
| 63 | + public static class KdsOrderLocationDto { | ||
| 64 | + private Integer orderId; | ||
| 65 | + private String roomNo; | ||
| 66 | + private String tableCode; | ||
| 67 | + private Integer totalCount; | ||
| 68 | + private String remark; | ||
| 69 | + private CustomerNotice customerNotice; | ||
| 70 | + private List<KdsOrderLocationDetailDto> orderDetailList; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + @Data | ||
| 74 | + @Builder | ||
| 75 | + @AllArgsConstructor | ||
| 76 | + @NoArgsConstructor | ||
| 77 | + @ApiModel(description = "KdsOrderSkuDto") | ||
| 78 | + public static class KdsOrderSkuQueryDto { | ||
| 79 | + private ServeStatusEnum serveStatus; | ||
| 80 | + private Integer categoryId; | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + @Data | ||
| 84 | + @Builder | ||
| 85 | + @AllArgsConstructor | ||
| 86 | + @NoArgsConstructor | ||
| 87 | + @ApiModel(description = "KdsOrderLocationQueryDto") | ||
| 88 | + public static class KdsOrderLocationQueryDto { | ||
| 89 | + private OrderStatusEnum orderStatus; | ||
| 90 | + private Integer categoryId; | ||
| 38 | } | 91 | } |
| 39 | } | 92 | } | ... | ... |
| ... | @@ -61,6 +61,24 @@ public class OrderDbDTO { | ... | @@ -61,6 +61,24 @@ public class OrderDbDTO { |
| 61 | private String keyword; | 61 | private String keyword; |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | +// enum OrderStatusEnum { | ||
| 65 | +// UNKNOWN_STATUS = 0; | ||
| 66 | +// TO_PREPARE = 1; | ||
| 67 | +// PREPARING = 2; | ||
| 68 | +// PARTIAL_SERVED = 3; | ||
| 69 | +// ALL_SERVED = 4; | ||
| 70 | +// ORDER_CANCELED = 5; | ||
| 71 | +// } | ||
| 72 | + @Data | ||
| 73 | + @Builder | ||
| 74 | + @ApiModel(description = "订单不同状态的数量Dto") | ||
| 75 | + public static class OrderCountByStatusDto { | ||
| 76 | + private Integer toPrepareCount; | ||
| 77 | + private Integer preparingCount; | ||
| 78 | + private Integer allServedCount; | ||
| 79 | + private Integer canceledCount; | ||
| 80 | + } | ||
| 81 | + | ||
| 64 | @Data | 82 | @Data |
| 65 | @Builder | 83 | @Builder |
| 66 | @ApiModel(description = "查询订单Dto") | 84 | @ApiModel(description = "查询订单Dto") |
| ... | @@ -90,6 +108,18 @@ public class OrderDbDTO { | ... | @@ -90,6 +108,18 @@ public class OrderDbDTO { |
| 90 | private Boolean shouldFilterCreatedAtTimeEnd = false; | 108 | private Boolean shouldFilterCreatedAtTimeEnd = false; |
| 91 | @Builder.Default | 109 | @Builder.Default |
| 92 | private LocalDateTime createdAtTimeEnd = LocalDateTime.now(); | 110 | private LocalDateTime createdAtTimeEnd = LocalDateTime.now(); |
| 111 | + @Builder.Default | ||
| 112 | + private Boolean shouldFilterClientIds = false; | ||
| 113 | + @Builder.Default | ||
| 114 | + private List<Integer> clientIds = new ArrayList<>(); | ||
| 115 | + @Builder.Default | ||
| 116 | + private Boolean shouldFilterStallIds = false; | ||
| 117 | + @Builder.Default | ||
| 118 | + private List<Integer> stallIds = new ArrayList<>(); | ||
| 119 | + @Builder.Default | ||
| 120 | + private Boolean shouldFilterStatus = false; | ||
| 121 | + @Builder.Default | ||
| 122 | + private OrderStatusEnum status = OrderStatusEnum.UNKNOWN_STATUS; | ||
| 93 | } | 123 | } |
| 94 | 124 | ||
| 95 | @Data | 125 | @Data | ... | ... |
| ... | @@ -27,6 +27,7 @@ public class SettlementDTO { | ... | @@ -27,6 +27,7 @@ public class SettlementDTO { |
| 27 | @ApiModel(description = "SettlementRequestDto") | 27 | @ApiModel(description = "SettlementRequestDto") |
| 28 | public static class SettlementMenuSkuDto { | 28 | public static class SettlementMenuSkuDto { |
| 29 | 29 | ||
| 30 | + private String skuCode; | ||
| 30 | private String showName; | 31 | private String showName; |
| 31 | private Integer count; | 32 | private Integer count; |
| 32 | private Integer price; | 33 | private Integer price; | ... | ... |
| 1 | package com.infoloop.tianting.service; | 1 | package com.infoloop.tianting.service; |
| 2 | 2 | ||
| 3 | +import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderLocationDto; | ||
| 4 | +import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderLocationQueryDto; | ||
| 5 | +import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderSkuDto; | ||
| 6 | +import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderSkuQueryDto; | ||
| 7 | +import java.util.List; | ||
| 8 | + | ||
| 3 | public interface KdsService { | 9 | public interface KdsService { |
| 4 | 10 | ||
| 11 | + List<KdsOrderSkuDto> getOrderDetailBySku(KdsOrderSkuQueryDto queryDto); | ||
| 12 | + | ||
| 13 | + List<KdsOrderLocationDto> getOrderDetailByLocation(KdsOrderLocationQueryDto queryDto); | ||
| 5 | } | 14 | } | ... | ... |
src/main/java/com/infoloop/tianting/service/client/EnterpriseResourceServiceRpcClient.java
0 → 100644
| 1 | +package com.infoloop.tianting.service.client; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.enterpriseresourcetagservice.EnterpriseResourceTagServiceRpcGrpc; | ||
| 4 | +import com.infoloop.tianting.enterpriseresourcetagservice.UserTagsAndResourcesGetRequest; | ||
| 5 | +import com.infoloop.tianting.enterpriseresourcetagservice.UserTagsAndResourcesGetResponse; | ||
| 6 | +import lombok.RequiredArgsConstructor; | ||
| 7 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 8 | +import org.springframework.stereotype.Service; | ||
| 9 | + | ||
| 10 | +@Service | ||
| 11 | +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) | ||
| 12 | +public class EnterpriseResourceServiceRpcClient { | ||
| 13 | + | ||
| 14 | + private final EnterpriseResourceTagServiceRpcGrpc.EnterpriseResourceTagServiceRpcBlockingStub | ||
| 15 | + enterpriseResourceTagServiceRpcBlockingStub; | ||
| 16 | + | ||
| 17 | + public UserTagsAndResourcesGetResponse getUserResources(Integer enterpriseId, Integer userId) { | ||
| 18 | + final var request = UserTagsAndResourcesGetRequest.newBuilder() | ||
| 19 | + .setSubjectId(enterpriseId) | ||
| 20 | + .setUserId(userId) | ||
| 21 | + .build(); | ||
| 22 | + return enterpriseResourceTagServiceRpcBlockingStub.getUserResources(request); | ||
| 23 | + } | ||
| 24 | +} |
| ... | @@ -75,6 +75,12 @@ public class OrderServiceRpcClient { | ... | @@ -75,6 +75,12 @@ public class OrderServiceRpcClient { |
| 75 | .setCreatedAtStart(queryOrderDto.getCreatedAtTimeStart().toInstant(ZoneOffset.UTC).toEpochMilli()) | 75 | .setCreatedAtStart(queryOrderDto.getCreatedAtTimeStart().toInstant(ZoneOffset.UTC).toEpochMilli()) |
| 76 | .setShouldFilterCreatedAtStart(queryOrderDto.getShouldFilterCreatedAtTimeEnd()) | 76 | .setShouldFilterCreatedAtStart(queryOrderDto.getShouldFilterCreatedAtTimeEnd()) |
| 77 | .setCreatedAtEnd(queryOrderDto.getCreatedAtTimeEnd().toInstant(ZoneOffset.UTC).toEpochMilli()) | 77 | .setCreatedAtEnd(queryOrderDto.getCreatedAtTimeEnd().toInstant(ZoneOffset.UTC).toEpochMilli()) |
| 78 | + .setShouldFilterClientIds(queryOrderDto.getShouldFilterClientIds()) | ||
| 79 | + .addAllClientIds(queryOrderDto.getClientIds()) | ||
| 80 | + .setShouldFilterStallIds(queryOrderDto.getShouldFilterStallIds()) | ||
| 81 | + .addAllStallIds(queryOrderDto.getStallIds()) | ||
| 82 | + .setShouldFilterStatus(queryOrderDto.getShouldFilterStatus()) | ||
| 83 | + .setStatus(queryOrderDto.getStatus()) | ||
| 78 | .build(); | 84 | .build(); |
| 79 | return orderServiceRpcBlockingStub.queryClientCustomerOrdersByCondition(request).getResponsesList(); | 85 | return orderServiceRpcBlockingStub.queryClientCustomerOrdersByCondition(request).getResponsesList(); |
| 80 | } | 86 | } | ... | ... |
| ... | @@ -3,10 +3,16 @@ package com.infoloop.tianting.service.impl; | ... | @@ -3,10 +3,16 @@ package com.infoloop.tianting.service.impl; |
| 3 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderDetailRpcResponse; | 3 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderDetailRpcResponse; |
| 4 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse; | 4 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse; |
| 5 | import com.infoloop.tianting.context.LoginContextHolder; | 5 | import com.infoloop.tianting.context.LoginContextHolder; |
| 6 | -import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderDto; | 6 | +import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderLocationDetailDto; |
| 7 | +import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderLocationDto; | ||
| 8 | +import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderLocationQueryDto; | ||
| 9 | +import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderSkuDetailDto; | ||
| 7 | import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderSkuDto; | 10 | import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderSkuDto; |
| 11 | +import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderSkuQueryDto; | ||
| 12 | +import com.infoloop.tianting.model.dto.OrderDbDTO.CustomerNotice; | ||
| 8 | import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByConditionDto; | 13 | import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByConditionDto; |
| 9 | import com.infoloop.tianting.service.KdsService; | 14 | import com.infoloop.tianting.service.KdsService; |
| 15 | +import com.infoloop.tianting.service.client.EnterpriseResourceServiceRpcClient; | ||
| 10 | import com.infoloop.tianting.service.client.MenuServiceRpcClient; | 16 | import com.infoloop.tianting.service.client.MenuServiceRpcClient; |
| 11 | import com.infoloop.tianting.service.client.OrderServiceRpcClient; | 17 | import com.infoloop.tianting.service.client.OrderServiceRpcClient; |
| 12 | import java.time.LocalDate; | 18 | import java.time.LocalDate; |
| ... | @@ -16,7 +22,6 @@ import java.util.List; | ... | @@ -16,7 +22,6 @@ import java.util.List; |
| 16 | import java.util.stream.Collectors; | 22 | import java.util.stream.Collectors; |
| 17 | import lombok.RequiredArgsConstructor; | 23 | import lombok.RequiredArgsConstructor; |
| 18 | import lombok.extern.slf4j.Slf4j; | 24 | import lombok.extern.slf4j.Slf4j; |
| 19 | -import org.apache.poi.hssf.record.DVALRecord; | ||
| 20 | import org.springframework.beans.factory.annotation.Autowired; | 25 | import org.springframework.beans.factory.annotation.Autowired; |
| 21 | import org.springframework.stereotype.Service; | 26 | import org.springframework.stereotype.Service; |
| 22 | 27 | ||
| ... | @@ -27,8 +32,10 @@ public class KdsServiceImpl implements KdsService { | ... | @@ -27,8 +32,10 @@ public class KdsServiceImpl implements KdsService { |
| 27 | 32 | ||
| 28 | private final OrderServiceRpcClient orderServiceRpcClient; | 33 | private final OrderServiceRpcClient orderServiceRpcClient; |
| 29 | private final MenuServiceRpcClient menuServiceRpcClient; | 34 | private final MenuServiceRpcClient menuServiceRpcClient; |
| 35 | + private final EnterpriseResourceServiceRpcClient enterpriseResourceServiceRpcClient; | ||
| 30 | 36 | ||
| 31 | - public void getOrderDetailBySku() { | 37 | + @Override |
| 38 | + public List<KdsOrderSkuDto> getOrderDetailBySku(KdsOrderSkuQueryDto queryDto) { | ||
| 32 | 39 | ||
| 33 | // 获取当日所有的订单 和 订单明细 | 40 | // 获取当日所有的订单 和 订单明细 |
| 34 | LocalDate today = LocalDate.now(); | 41 | LocalDate today = LocalDate.now(); |
| ... | @@ -37,8 +44,16 @@ public class KdsServiceImpl implements KdsService { | ... | @@ -37,8 +44,16 @@ public class KdsServiceImpl implements KdsService { |
| 37 | LocalDateTime tomorrowZero = tomorrow.atStartOfDay(); | 44 | LocalDateTime tomorrowZero = tomorrow.atStartOfDay(); |
| 38 | 45 | ||
| 39 | final var operatorLoginInfo = LoginContextHolder.getLoginInfo(); | 46 | final var operatorLoginInfo = LoginContextHolder.getLoginInfo(); |
| 47 | + | ||
| 48 | + final var userResource = enterpriseResourceServiceRpcClient.getUserResources( | ||
| 49 | + operatorLoginInfo.getEnterpriseId(), operatorLoginInfo.getId()); | ||
| 50 | + | ||
| 40 | final var queryOrderDto = QueryOrderByConditionDto.builder() | 51 | final var queryOrderDto = QueryOrderByConditionDto.builder() |
| 41 | .enterpriseId(operatorLoginInfo.getEnterpriseId()) | 52 | .enterpriseId(operatorLoginInfo.getEnterpriseId()) |
| 53 | + .shouldFilterClientIds(true) | ||
| 54 | + .clientIds(userResource.getClientIdsList()) | ||
| 55 | + .shouldFilterStallIds(true) | ||
| 56 | + .stallIds(userResource.getStallIdsList()) | ||
| 42 | .shouldFilterCreatedAtTimeStart(true) | 57 | .shouldFilterCreatedAtTimeStart(true) |
| 43 | .createdAtTimeStart(todayZero) | 58 | .createdAtTimeStart(todayZero) |
| 44 | .shouldFilterCreatedAtTimeEnd(true) | 59 | .shouldFilterCreatedAtTimeEnd(true) |
| ... | @@ -50,22 +65,25 @@ public class KdsServiceImpl implements KdsService { | ... | @@ -50,22 +65,25 @@ public class KdsServiceImpl implements KdsService { |
| 50 | .distinct() | 65 | .distinct() |
| 51 | .collect(Collectors.toList()); | 66 | .collect(Collectors.toList()); |
| 52 | final var orderDetailList = orderServiceRpcClient.getOrderDetailsByOrderIds(orderIds); | 67 | final var orderDetailList = orderServiceRpcClient.getOrderDetailsByOrderIds(orderIds); |
| 68 | + final var filteredOrderDetailList = orderDetailList.stream() | ||
| 69 | + .filter(od -> od.getServeStatus() == queryDto.getServeStatus() && od.getCategoryId() == queryDto.getCategoryId()) | ||
| 70 | + .collect(Collectors.toList()); | ||
| 53 | 71 | ||
| 54 | //在所有的orderDetail里找出所有所有不同的menuDetailId,然后根据menuDetailId进行分类 | 72 | //在所有的orderDetail里找出所有所有不同的menuDetailId,然后根据menuDetailId进行分类 |
| 55 | - final var menuDetailIds = orderDetailList.stream() | 73 | + final var menuDetailIds = filteredOrderDetailList.stream() |
| 56 | .map(SingleClientCustomerOrderDetailRpcResponse::getMenuDetailId) | 74 | .map(SingleClientCustomerOrderDetailRpcResponse::getMenuDetailId) |
| 57 | .distinct() | 75 | .distinct() |
| 58 | .collect(Collectors.toList()); | 76 | .collect(Collectors.toList()); |
| 59 | List<KdsOrderSkuDto> kdsOrderSkuList = new ArrayList<>(); | 77 | List<KdsOrderSkuDto> kdsOrderSkuList = new ArrayList<>(); |
| 60 | for (Integer menuDetailId: menuDetailIds) { | 78 | for (Integer menuDetailId: menuDetailIds) { |
| 61 | // 找出该menuDetailId 的所有orderDetail | 79 | // 找出该menuDetailId 的所有orderDetail |
| 62 | - final var curOrderDetails = orderDetailList.stream() | 80 | + final var curOrderDetails = filteredOrderDetailList.stream() |
| 63 | .filter(d-> d.getMenuDetailId() == menuDetailId) | 81 | .filter(d-> d.getMenuDetailId() == menuDetailId) |
| 64 | .collect(Collectors.toList()); | 82 | .collect(Collectors.toList()); |
| 65 | final var totalCount = curOrderDetails.stream() | 83 | final var totalCount = curOrderDetails.stream() |
| 66 | .mapToInt(SingleClientCustomerOrderDetailRpcResponse::getCount) | 84 | .mapToInt(SingleClientCustomerOrderDetailRpcResponse::getCount) |
| 67 | .sum(); | 85 | .sum(); |
| 68 | - List<KdsOrderDto> kdsOrders = new ArrayList<>(); | 86 | + List<KdsOrderSkuDetailDto> kdsOrders = new ArrayList<>(); |
| 69 | for(SingleClientCustomerOrderDetailRpcResponse detail: curOrderDetails) { | 87 | for(SingleClientCustomerOrderDetailRpcResponse detail: curOrderDetails) { |
| 70 | final var order = orderList.stream() | 88 | final var order = orderList.stream() |
| 71 | .filter(o -> o.getId() == detail.getOrderId()) | 89 | .filter(o -> o.getId() == detail.getOrderId()) |
| ... | @@ -73,13 +91,18 @@ public class KdsServiceImpl implements KdsService { | ... | @@ -73,13 +91,18 @@ public class KdsServiceImpl implements KdsService { |
| 73 | if (order.isEmpty()) { | 91 | if (order.isEmpty()) { |
| 74 | continue; | 92 | continue; |
| 75 | } | 93 | } |
| 76 | - final var kdsOrder = KdsOrderDto.builder() | 94 | + final var kdsOrder = KdsOrderSkuDetailDto.builder() |
| 77 | .count(detail.getCount()) | 95 | .count(detail.getCount()) |
| 78 | .orderDetailId(detail.getId()) | 96 | .orderDetailId(detail.getId()) |
| 79 | .remark(order.get().getRemark()) | 97 | .remark(order.get().getRemark()) |
| 80 | .orderId(order.get().getId()) | 98 | .orderId(order.get().getId()) |
| 81 | .roomNo(order.get().getRoomNo()) | 99 | .roomNo(order.get().getRoomNo()) |
| 82 | .tableCode(order.get().getTableCode()) | 100 | .tableCode(order.get().getTableCode()) |
| 101 | + .customerNotice(CustomerNotice.builder() | ||
| 102 | + .doctors(order.get().getCustomerNoticeJson().getDoctorsList()) | ||
| 103 | + .avoids(order.get().getCustomerNoticeJson().getAvoidsList()) | ||
| 104 | + .build()) | ||
| 105 | + .adjustSkuRemark(detail.getAdjustSkuRemark()) | ||
| 83 | .build(); | 106 | .build(); |
| 84 | kdsOrders.add(kdsOrder); | 107 | kdsOrders.add(kdsOrder); |
| 85 | } | 108 | } |
| ... | @@ -93,9 +116,82 @@ public class KdsServiceImpl implements KdsService { | ... | @@ -93,9 +116,82 @@ public class KdsServiceImpl implements KdsService { |
| 93 | 116 | ||
| 94 | } | 117 | } |
| 95 | 118 | ||
| 119 | + return kdsOrderSkuList; | ||
| 120 | + | ||
| 121 | + } | ||
| 96 | 122 | ||
| 123 | + public List<KdsOrderLocationDto> getOrderDetailByLocation(KdsOrderLocationQueryDto queryDto) { | ||
| 124 | + // 获取当日所有的订单 和 订单明细 | ||
| 125 | + LocalDate today = LocalDate.now(); | ||
| 126 | + LocalDateTime todayZero = today.atStartOfDay(); | ||
| 127 | + LocalDate tomorrow = today.plusDays(1); | ||
| 128 | + LocalDateTime tomorrowZero = tomorrow.atStartOfDay(); | ||
| 97 | 129 | ||
| 130 | + final var operatorLoginInfo = LoginContextHolder.getLoginInfo(); | ||
| 131 | + | ||
| 132 | + final var userResource = enterpriseResourceServiceRpcClient.getUserResources( | ||
| 133 | + operatorLoginInfo.getEnterpriseId(), operatorLoginInfo.getId()); | ||
| 134 | + | ||
| 135 | + final var queryOrderDto = QueryOrderByConditionDto.builder() | ||
| 136 | + .enterpriseId(operatorLoginInfo.getEnterpriseId()) | ||
| 137 | + .shouldFilterClientIds(true) | ||
| 138 | + .clientIds(userResource.getClientIdsList()) | ||
| 139 | + .shouldFilterStallIds(true) | ||
| 140 | + .stallIds(userResource.getStallIdsList()) | ||
| 141 | + .shouldFilterCreatedAtTimeStart(true) | ||
| 142 | + .createdAtTimeStart(todayZero) | ||
| 143 | + .shouldFilterCreatedAtTimeEnd(true) | ||
| 144 | + .createdAtTimeEnd(tomorrowZero) | ||
| 145 | + .shouldFilterStatus(true) | ||
| 146 | + .status(queryDto.getOrderStatus()) | ||
| 147 | + .build(); | ||
| 148 | + final var orderList = orderServiceRpcClient.getOrdersByCondition(queryOrderDto); | ||
| 149 | + List<Integer> orderIds = orderList.stream() | ||
| 150 | + .map(SingleClientCustomerOrderRpcResponse::getId) | ||
| 151 | + .distinct() | ||
| 152 | + .collect(Collectors.toList()); | ||
| 153 | + final var orderDetailList = orderServiceRpcClient.getOrderDetailsByOrderIds(orderIds); | ||
| 154 | + final var filteredOrderDetailList = orderDetailList.stream() | ||
| 155 | + .filter(od -> od.getCategoryId() == queryDto.getCategoryId()) | ||
| 156 | + .collect(Collectors.toList()); | ||
| 157 | + | ||
| 158 | + //在所有的orderDetail里找出所有所有不同的menuDetailId,然后根据menuDetailId进行分类 | ||
| 159 | + final var menuDetailIds = filteredOrderDetailList.stream() | ||
| 160 | + .map(SingleClientCustomerOrderDetailRpcResponse::getMenuDetailId) | ||
| 161 | + .distinct() | ||
| 162 | + .collect(Collectors.toList()); | ||
| 163 | + | ||
| 164 | + List<KdsOrderLocationDto> kdsOrderLocationList = new ArrayList<>(); | ||
| 165 | + | ||
| 166 | + for (SingleClientCustomerOrderRpcResponse order: orderList) { | ||
| 167 | + final var curOrderDetails = filteredOrderDetailList.stream() | ||
| 168 | + .filter(d-> d.getOrderId() == order.getId()) | ||
| 169 | + .collect(Collectors.toList()); | ||
| 170 | + final var kdsOrderDetails = curOrderDetails.stream().map(od -> | ||
| 171 | + KdsOrderLocationDetailDto.builder() | ||
| 172 | + .adjustSkuRemark(od.getAdjustSkuRemark()) | ||
| 173 | + .count(od.getCount()) | ||
| 174 | + .orderDetailId(od.getId()) | ||
| 175 | + .serveStatus(od.getServeStatus()) | ||
| 176 | + .showName(od.getShowName()) | ||
| 177 | + .build() | ||
| 178 | + ).collect(Collectors.toList()); | ||
| 179 | + final var kdsOrder = KdsOrderLocationDto.builder() | ||
| 180 | + .totalCount(order.getTotalNum()) | ||
| 181 | + .remark(order.getRemark()) | ||
| 182 | + .orderId(order.getId()) | ||
| 183 | + .roomNo(order.getRoomNo()) | ||
| 184 | + .tableCode(order.getTableCode()) | ||
| 185 | + .customerNotice(CustomerNotice.builder() | ||
| 186 | + .doctors(order.getCustomerNoticeJson().getDoctorsList()) | ||
| 187 | + .avoids(order.getCustomerNoticeJson().getAvoidsList()) | ||
| 188 | + .build()) | ||
| 189 | + .orderDetailList(kdsOrderDetails) | ||
| 190 | + .build(); | ||
| 191 | + kdsOrderLocationList.add(kdsOrder); | ||
| 192 | + } | ||
| 98 | 193 | ||
| 194 | + return kdsOrderLocationList; | ||
| 99 | } | 195 | } |
| 100 | 196 | ||
| 101 | 197 | ... | ... |
| ... | @@ -7,6 +7,7 @@ import com.infoloop.tianting.exception.ClientEndExceptions.BusinessException; | ... | @@ -7,6 +7,7 @@ import com.infoloop.tianting.exception.ClientEndExceptions.BusinessException; |
| 7 | import com.infoloop.tianting.exception.ErrorCodeEnum; | 7 | import com.infoloop.tianting.exception.ErrorCodeEnum; |
| 8 | import com.infoloop.tianting.menuservice.SingleMenuDetailRpcResponse; | 8 | import com.infoloop.tianting.menuservice.SingleMenuDetailRpcResponse; |
| 9 | import com.infoloop.tianting.menuservice.SingleMenuRpcResponse; | 9 | import com.infoloop.tianting.menuservice.SingleMenuRpcResponse; |
| 10 | +import com.infoloop.tianting.model.common.ResponseResult; | ||
| 10 | import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByConditionDto; | 11 | import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByConditionDto; |
| 11 | import com.infoloop.tianting.model.dto.SettlementDTO.SettlementMenuSkuDto; | 12 | import com.infoloop.tianting.model.dto.SettlementDTO.SettlementMenuSkuDto; |
| 12 | import com.infoloop.tianting.model.dto.SettlementDTO.SettlementRequestDto; | 13 | import com.infoloop.tianting.model.dto.SettlementDTO.SettlementRequestDto; |
| ... | @@ -14,6 +15,7 @@ import com.infoloop.tianting.service.OrderService; | ... | @@ -14,6 +15,7 @@ import com.infoloop.tianting.service.OrderService; |
| 14 | import com.infoloop.tianting.service.SettlementService; | 15 | import com.infoloop.tianting.service.SettlementService; |
| 15 | import com.infoloop.tianting.service.client.MenuServiceRpcClient; | 16 | import com.infoloop.tianting.service.client.MenuServiceRpcClient; |
| 16 | import com.infoloop.tianting.service.client.OrderServiceRpcClient; | 17 | import com.infoloop.tianting.service.client.OrderServiceRpcClient; |
| 18 | +import com.infoloop.tianting.service.client.SkuServiceRpcClient; | ||
| 17 | import com.infoloop.tianting.utils.DateUtil; | 19 | import com.infoloop.tianting.utils.DateUtil; |
| 18 | import java.io.ByteArrayOutputStream; | 20 | import java.io.ByteArrayOutputStream; |
| 19 | import java.io.FileOutputStream; | 21 | import java.io.FileOutputStream; |
| ... | @@ -41,6 +43,7 @@ import org.springframework.stereotype.Service; | ... | @@ -41,6 +43,7 @@ import org.springframework.stereotype.Service; |
| 41 | public class SettlementServiceImpl implements SettlementService { | 43 | public class SettlementServiceImpl implements SettlementService { |
| 42 | private final OrderServiceRpcClient orderServiceRpcClient; | 44 | private final OrderServiceRpcClient orderServiceRpcClient; |
| 43 | private final MenuServiceRpcClient menuServiceRpcClient; | 45 | private final MenuServiceRpcClient menuServiceRpcClient; |
| 46 | + private final SkuServiceRpcClient skuServiceRpcClient; | ||
| 44 | 47 | ||
| 45 | @Override | 48 | @Override |
| 46 | public ByteArrayOutputStream generateOrderSettlementExcel(SettlementRequestDto settlementRequest) { | 49 | public ByteArrayOutputStream generateOrderSettlementExcel(SettlementRequestDto settlementRequest) { |
| ... | @@ -58,18 +61,27 @@ public class SettlementServiceImpl implements SettlementService { | ... | @@ -58,18 +61,27 @@ public class SettlementServiceImpl implements SettlementService { |
| 58 | SingleClientCustomerOrderRpcResponse::getId).distinct() | 61 | SingleClientCustomerOrderRpcResponse::getId).distinct() |
| 59 | .collect(Collectors.toList()); | 62 | .collect(Collectors.toList()); |
| 60 | final var orderDetailList = orderServiceRpcClient.getOrderDetailsByOrderIds(orderIds); | 63 | final var orderDetailList = orderServiceRpcClient.getOrderDetailsByOrderIds(orderIds); |
| 64 | + List<Integer> skuIds = orderDetailList.stream() | ||
| 65 | + .map(SingleClientCustomerOrderDetailRpcResponse::getSkuId) | ||
| 66 | + .distinct() | ||
| 67 | + .collect(Collectors.toList()); | ||
| 68 | + final var skus = skuServiceRpcClient.getDishSkusByIds(skuIds).getResponseList(); | ||
| 61 | 69 | ||
| 62 | List<Integer> menuIds = orderList.stream().map( | 70 | List<Integer> menuIds = orderList.stream().map( |
| 63 | SingleClientCustomerOrderRpcResponse::getMenuId).distinct() | 71 | SingleClientCustomerOrderRpcResponse::getMenuId).distinct() |
| 64 | .collect(Collectors.toList()); | 72 | .collect(Collectors.toList()); |
| 65 | - final var menuList = menuServiceRpcClient.getMenusByIds(operatorLoginInfo.getEnterpriseId(), menuIds); | 73 | + final var menuList = menuServiceRpcClient |
| 74 | + .getMenusByIds(operatorLoginInfo.getEnterpriseId(), menuIds) | ||
| 75 | + .getResponsesList(); | ||
| 66 | final var menuDetailList = menuServiceRpcClient.queryMenuDetailsByMenuIds( | 76 | final var menuDetailList = menuServiceRpcClient.queryMenuDetailsByMenuIds( |
| 67 | operatorLoginInfo.getEnterpriseId(), menuIds).getResponsesList(); | 77 | operatorLoginInfo.getEnterpriseId(), menuIds).getResponsesList(); |
| 68 | - Map<String, Map<Integer, List<SettlementMenuSkuDto>>> classifyOrders = new HashMap<>(); | 78 | + |
| 79 | + Map<String, Map<String, List<SettlementMenuSkuDto>>> classifyOrders = new HashMap<>(); | ||
| 69 | 80 | ||
| 70 | //找出所有需要的日期 | 81 | //找出所有需要的日期 |
| 71 | final var dates = orderList.stream() | 82 | final var dates = orderList.stream() |
| 72 | .map(o -> DateUtil.formatDate(o.getCreatedAt(), DateUtil.YYYY_MM_DD)) | 83 | .map(o -> DateUtil.formatDate(o.getCreatedAt(), DateUtil.YYYY_MM_DD)) |
| 84 | + .distinct() | ||
| 73 | .collect(Collectors.toList()); | 85 | .collect(Collectors.toList()); |
| 74 | for(String date: dates) { | 86 | for(String date: dates) { |
| 75 | 87 | ||
| ... | @@ -89,10 +101,16 @@ public class SettlementServiceImpl implements SettlementService { | ... | @@ -89,10 +101,16 @@ public class SettlementServiceImpl implements SettlementService { |
| 89 | // 找出当天已点的所有餐单 | 101 | // 找出当天已点的所有餐单 |
| 90 | final var curMenuIds = curOrderList.stream() | 102 | final var curMenuIds = curOrderList.stream() |
| 91 | .map(SingleClientCustomerOrderRpcResponse::getMenuId) | 103 | .map(SingleClientCustomerOrderRpcResponse::getMenuId) |
| 104 | + .distinct() | ||
| 92 | .collect(Collectors.toList()); | 105 | .collect(Collectors.toList()); |
| 93 | for (Integer curMenuId: curMenuIds) { | 106 | for (Integer curMenuId: curMenuIds) { |
| 94 | - if (!menusMap.containsKey(curMenuId)) { | 107 | + final var curMenu = menuList.stream().filter(m -> m.getId() == curMenuId).findFirst(); |
| 95 | - menusMap.put(curMenuId, new ArrayList<>()); | 108 | + if (curMenu.isEmpty()) { |
| 109 | + continue; | ||
| 110 | + } | ||
| 111 | + final var curMenuName = curMenu.get().getName(); | ||
| 112 | + if (!menusMap.containsKey(curMenuName)) { | ||
| 113 | + menusMap.put(curMenuName, new ArrayList<>()); | ||
| 96 | } | 114 | } |
| 97 | final var menuSkuList = new ArrayList<SettlementMenuSkuDto>(); | 115 | final var menuSkuList = new ArrayList<SettlementMenuSkuDto>(); |
| 98 | // 找出当天餐单所有的菜品 | 116 | // 找出当天餐单所有的菜品 |
| ... | @@ -118,7 +136,17 @@ public class SettlementServiceImpl implements SettlementService { | ... | @@ -118,7 +136,17 @@ public class SettlementServiceImpl implements SettlementService { |
| 118 | .map(SingleClientCustomerOrderDetailRpcResponse::getCount) | 136 | .map(SingleClientCustomerOrderDetailRpcResponse::getCount) |
| 119 | .collect(Collectors.toList()); | 137 | .collect(Collectors.toList()); |
| 120 | int countTotal = countList.stream().mapToInt(Integer::intValue).sum(); | 138 | int countTotal = countList.stream().mapToInt(Integer::intValue).sum(); |
| 139 | + if (countTotal <= 0) { | ||
| 140 | + continue; | ||
| 141 | + } | ||
| 142 | + // 找出该sku的code | ||
| 143 | + final var curSku = skus.stream().filter(s -> s.getId() == m.getSkuId()).findFirst(); | ||
| 144 | + String skuCode = ""; | ||
| 145 | + if (curSku.isPresent()) { | ||
| 146 | + skuCode = curSku.get().getCode(); | ||
| 147 | + } | ||
| 121 | final var settlementMenuSku = SettlementMenuSkuDto.builder() | 148 | final var settlementMenuSku = SettlementMenuSkuDto.builder() |
| 149 | + .skuCode(skuCode) | ||
| 122 | .count(countTotal) | 150 | .count(countTotal) |
| 123 | .showName(m.getShowName()) | 151 | .showName(m.getShowName()) |
| 124 | .price(m.getPrice()) | 152 | .price(m.getPrice()) |
| ... | @@ -127,8 +155,7 @@ public class SettlementServiceImpl implements SettlementService { | ... | @@ -127,8 +155,7 @@ public class SettlementServiceImpl implements SettlementService { |
| 127 | menuSkuList.add(settlementMenuSku); | 155 | menuSkuList.add(settlementMenuSku); |
| 128 | 156 | ||
| 129 | } | 157 | } |
| 130 | - menusMap.get(curMenuId).addAll(menuSkuList); | 158 | + menusMap.get(curMenuName).addAll(menuSkuList); |
| 131 | - | ||
| 132 | 159 | ||
| 133 | } | 160 | } |
| 134 | } | 161 | } |
| ... | @@ -142,60 +169,88 @@ public class SettlementServiceImpl implements SettlementService { | ... | @@ -142,60 +169,88 @@ public class SettlementServiceImpl implements SettlementService { |
| 142 | 169 | ||
| 143 | } | 170 | } |
| 144 | 171 | ||
| 145 | - public static ByteArrayOutputStream writeToExcel(Map<String, Map<Integer, List<SettlementMenuSkuDto>>> classifyOrders) | 172 | + public static ByteArrayOutputStream writeToExcel(Map<String, Map<String, List<SettlementMenuSkuDto>>> classifyOrders) |
| 146 | throws IOException { | 173 | throws IOException { |
| 147 | Workbook workbook = new XSSFWorkbook(); | 174 | Workbook workbook = new XSSFWorkbook(); |
| 148 | Sheet sheet = workbook.createSheet("订单数据"); | 175 | Sheet sheet = workbook.createSheet("订单数据"); |
| 149 | 176 | ||
| 150 | int rowNum = 0; | 177 | int rowNum = 0; |
| 151 | - for (Map.Entry<String, Map<Integer, List<SettlementMenuSkuDto>>> outerEntry : classifyOrders.entrySet()) { | 178 | + Row titleRow = sheet.createRow(rowNum++); |
| 179 | + Cell dateTitleCell = titleRow.createCell(0); | ||
| 180 | + dateTitleCell.setCellValue("点餐日期"); | ||
| 181 | + Cell menuTitleCell = titleRow.createCell(1); | ||
| 182 | + menuTitleCell.setCellValue("餐单名称"); | ||
| 183 | + Cell skuCodeTitleCell = titleRow.createCell(2); | ||
| 184 | + skuCodeTitleCell.setCellValue("菜品编号"); | ||
| 185 | + | ||
| 186 | + Cell skuNameTitleCell = titleRow.createCell(3); | ||
| 187 | + skuNameTitleCell.setCellValue("菜品名称"); | ||
| 188 | + Cell skuPriceTitleCell = titleRow.createCell(4); | ||
| 189 | + skuPriceTitleCell.setCellValue("单价"); | ||
| 190 | + Cell skuCountTitleCell = titleRow.createCell(5); | ||
| 191 | + skuCountTitleCell.setCellValue("数量"); | ||
| 192 | + Cell skuTotalPriceTitleCell = titleRow.createCell(6); | ||
| 193 | + skuTotalPriceTitleCell.setCellValue("合计金额"); | ||
| 194 | + | ||
| 195 | + for (Map.Entry<String, Map<String, List<SettlementMenuSkuDto>>> outerEntry : classifyOrders.entrySet()) { | ||
| 152 | String orderDate = outerEntry.getKey(); | 196 | String orderDate = outerEntry.getKey(); |
| 153 | - Map<Integer, List<SettlementMenuSkuDto>> innerMap = outerEntry.getValue(); | 197 | + Map<String, List<SettlementMenuSkuDto>> innerMap = outerEntry.getValue(); |
| 198 | + Integer curDateTotalRow = 0; | ||
| 199 | + for (Map.Entry<String, List<SettlementMenuSkuDto>> innerEntry : innerMap.entrySet()) { | ||
| 200 | + curDateTotalRow += innerEntry.getValue().size(); | ||
| 201 | + } | ||
| 154 | 202 | ||
| 155 | // 写入日期列并合并单元格 | 203 | // 写入日期列并合并单元格 |
| 156 | int startRowForDate = rowNum; | 204 | int startRowForDate = rowNum; |
| 157 | - for (int i = 0; i < innerMap.size() * 2; i++) { | 205 | + for (int i = 0; i < curDateTotalRow; i++) { |
| 158 | Row dateRow = sheet.createRow(rowNum++); | 206 | Row dateRow = sheet.createRow(rowNum++); |
| 159 | Cell dateCell = dateRow.createCell(0); | 207 | Cell dateCell = dateRow.createCell(0); |
| 160 | dateCell.setCellValue(orderDate); | 208 | dateCell.setCellValue(orderDate); |
| 161 | } | 209 | } |
| 162 | int endRowForDate = rowNum - 1; | 210 | int endRowForDate = rowNum - 1; |
| 163 | - if (endRowForDate >= startRowForDate) { | 211 | + if (endRowForDate > startRowForDate) { |
| 164 | - CellRangeAddress region = new CellRangeAddress(startRowForDate, endRowForDate, 0, 0); | 212 | + CellRangeAddress dateRegion = new CellRangeAddress(startRowForDate, endRowForDate, 0, 0); |
| 165 | - sheet.addMergedRegion(region); | 213 | + sheet.addMergedRegion(dateRegion); |
| 166 | } | 214 | } |
| 167 | 215 | ||
| 168 | - for (Map.Entry<Integer, List<SettlementMenuSkuDto>> innerEntry : innerMap.entrySet()) { | 216 | + rowNum = startRowForDate; |
| 169 | - int menuId = innerEntry.getKey(); | 217 | + for (Map.Entry<String, List<SettlementMenuSkuDto>> innerEntry : innerMap.entrySet()) { |
| 218 | + String menuName = innerEntry.getKey(); | ||
| 170 | List<SettlementMenuSkuDto> skuList = innerEntry.getValue(); | 219 | List<SettlementMenuSkuDto> skuList = innerEntry.getValue(); |
| 171 | 220 | ||
| 172 | // 写入菜单ID列并合并单元格 | 221 | // 写入菜单ID列并合并单元格 |
| 173 | int startRowForMenu = rowNum; | 222 | int startRowForMenu = rowNum; |
| 174 | for (int i = 0; i < skuList.size(); i++) { | 223 | for (int i = 0; i < skuList.size(); i++) { |
| 175 | - Row menuRow = sheet.createRow(rowNum++); | 224 | + Row menuRow = sheet.getRow(rowNum++); |
| 176 | Cell menuCell = menuRow.createCell(1); | 225 | Cell menuCell = menuRow.createCell(1); |
| 177 | - menuCell.setCellValue(menuId); | 226 | + menuCell.setCellValue(menuName); |
| 178 | } | 227 | } |
| 179 | int endRowForMenu = rowNum - 1; | 228 | int endRowForMenu = rowNum - 1; |
| 180 | - if (endRowForMenu >= startRowForMenu) { | 229 | + if (endRowForMenu > startRowForMenu) { |
| 181 | - CellRangeAddress region = new CellRangeAddress(startRowForMenu, endRowForMenu, 1, 1); | 230 | + CellRangeAddress menuRegion = new CellRangeAddress(startRowForMenu, endRowForMenu, 1, 1); |
| 182 | - sheet.addMergedRegion(region); | 231 | + sheet.addMergedRegion(menuRegion); |
| 183 | } | 232 | } |
| 184 | 233 | ||
| 185 | // 写入SKU列 | 234 | // 写入SKU列 |
| 235 | + rowNum = startRowForMenu; | ||
| 186 | for (SettlementMenuSkuDto skuDto : skuList) { | 236 | for (SettlementMenuSkuDto skuDto : skuList) { |
| 187 | - Row skuRow = sheet.createRow(rowNum++); | 237 | + Row skuRow = sheet.getRow(rowNum++); |
| 188 | - Cell skuCell = skuRow.createCell(2); | 238 | + Cell skuCodeCell = skuRow.createCell(2); |
| 189 | - skuCell.setCellValue(skuDto.getShowName()); | 239 | + skuCodeCell.setCellValue(skuDto.getSkuCode()); |
| 190 | - skuCell.setCellValue(skuDto.getPrice()); | 240 | + Cell showNameCell = skuRow.createCell(3); |
| 191 | - skuCell.setCellValue(skuDto.getCount()); | 241 | + showNameCell.setCellValue(skuDto.getShowName()); |
| 192 | - skuCell.setCellValue(skuDto.getTotalPrice()); | 242 | + Cell priceCell = skuRow.createCell(4); |
| 243 | + priceCell.setCellValue((double)skuDto.getPrice()/100); | ||
| 244 | + Cell countCell = skuRow.createCell(5); | ||
| 245 | + countCell.setCellValue(skuDto.getCount()); | ||
| 246 | + Cell totalPriceCell = skuRow.createCell(6); | ||
| 247 | + totalPriceCell.setCellValue((double)skuDto.getTotalPrice()/100); | ||
| 193 | } | 248 | } |
| 194 | } | 249 | } |
| 195 | } | 250 | } |
| 196 | 251 | ||
| 197 | // 自动调整列宽 | 252 | // 自动调整列宽 |
| 198 | - for (int i = 0; i < 6; i++) { | 253 | + for (int i = 0; i < 7; i++) { |
| 199 | sheet.autoSizeColumn(i); | 254 | sheet.autoSizeColumn(i); |
| 200 | } | 255 | } |
| 201 | 256 | ... | ... |
| 1 | -package com.infoloop.tianting.controller; | 1 | +package com.infoloop.tianting.streamController; |
| 2 | 2 | ||
| 3 | import com.github.xiaoymin.knife4j.annotations.ApiSupport; | 3 | import com.github.xiaoymin.knife4j.annotations.ApiSupport; |
| 4 | +import com.infoloop.tianting.model.common.ResponseResult; | ||
| 4 | import com.infoloop.tianting.model.dto.SettlementDTO.SettlementRequestDto; | 5 | import com.infoloop.tianting.model.dto.SettlementDTO.SettlementRequestDto; |
| 5 | import com.infoloop.tianting.service.SettlementService; | 6 | import com.infoloop.tianting.service.SettlementService; |
| 6 | import io.swagger.annotations.Api; | 7 | import io.swagger.annotations.Api; |
| ... | @@ -30,20 +31,19 @@ import org.springframework.web.bind.annotation.RestController; | ... | @@ -30,20 +31,19 @@ import org.springframework.web.bind.annotation.RestController; |
| 30 | public class SettlementController { | 31 | public class SettlementController { |
| 31 | private final SettlementService settlementService; | 32 | private final SettlementService settlementService; |
| 32 | 33 | ||
| 33 | - @ApiOperation(value = "结算账单生成excel") | 34 | + @ApiOperation(value = "结算账单生成excel") |
| 34 | - @PostMapping("/settlement/generate-excel") | 35 | + @PostMapping("/settlement/generate-excel") |
| 35 | - @ResponseStatus(HttpStatus.OK) | 36 | + @ResponseStatus(HttpStatus.OK) |
| 36 | - public ResponseEntity<byte[]> settlementGenerateExcel( | 37 | + public ResponseEntity<byte[]> settlementGenerateExcel( |
| 37 | - @Valid @RequestBody SettlementRequestDto settlementRequestDto) { | 38 | + @Valid @RequestBody SettlementRequestDto settlementRequestDto) { |
| 38 | - ByteArrayOutputStream outputStream = settlementService.generateOrderSettlementExcel( | 39 | + ByteArrayOutputStream outputStream = settlementService.generateOrderSettlementExcel( |
| 39 | - settlementRequestDto); | 40 | + settlementRequestDto); |
| 40 | - HttpHeaders headers = new HttpHeaders(); | 41 | + HttpHeaders headers = new HttpHeaders(); |
| 41 | - headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); | 42 | + headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); |
| 42 | - headers.setContentDispositionFormData("attachment", "订单数据.xlsx"); | 43 | + headers.setContentDispositionFormData("attachment", "订单数据.xlsx"); |
| 43 | - | ||
| 44 | - return ResponseEntity.ok() | ||
| 45 | - .headers(headers) | ||
| 46 | - .body(outputStream.toByteArray()); | ||
| 47 | - } | ||
| 48 | 44 | ||
| 45 | + return ResponseEntity.ok() | ||
| 46 | + .headers(headers) | ||
| 47 | + .body(outputStream.toByteArray()); | ||
| 48 | + } | ||
| 49 | } | 49 | } | ... | ... |
| 1 | package com.infoloop.tianting.utils; | 1 | package com.infoloop.tianting.utils; |
| 2 | 2 | ||
| 3 | +import com.infoloop.tianting.model.common.OrderPageResult; | ||
| 3 | import com.infoloop.tianting.model.common.PageResult; | 4 | import com.infoloop.tianting.model.common.PageResult; |
| 4 | 5 | ||
| 6 | +import com.infoloop.tianting.model.dto.OrderDbDTO.OrderCountByStatusDto; | ||
| 5 | import java.util.LinkedList; | 7 | import java.util.LinkedList; |
| 6 | import java.util.List; | 8 | import java.util.List; |
| 7 | 9 | ||
| ... | @@ -42,4 +44,15 @@ public class PageUtil { | ... | @@ -42,4 +44,15 @@ public class PageUtil { |
| 42 | pageRet.setTotalPage(pages); | 44 | pageRet.setTotalPage(pages); |
| 43 | return pageRet; | 45 | return pageRet; |
| 44 | } | 46 | } |
| 47 | + | ||
| 48 | + public static <T> OrderPageResult<T> from(List<T> list, long totalCount, long pages, int pageNo, int pageSize, OrderCountByStatusDto countByStatus) { | ||
| 49 | + OrderPageResult<T> pageRet = new OrderPageResult<T>(); | ||
| 50 | + pageRet.setTotalCount(totalCount); | ||
| 51 | + pageRet.setDataList(list); | ||
| 52 | + pageRet.setPageNo(pageNo); | ||
| 53 | + pageRet.setPageSize(pageSize); | ||
| 54 | + pageRet.setTotalPage(pages); | ||
| 55 | + pageRet.setCountByStatus(countByStatus); | ||
| 56 | + return pageRet; | ||
| 57 | + } | ||
| 45 | } | 58 | } | ... | ... |
| ... | @@ -67,6 +67,9 @@ grpc.operator-service.port=3031 | ... | @@ -67,6 +67,9 @@ grpc.operator-service.port=3031 |
| 67 | grpc.woperator-service.url=47.101.193.136 | 67 | grpc.woperator-service.url=47.101.193.136 |
| 68 | grpc.woperator-service.port=3028 | 68 | grpc.woperator-service.port=3028 |
| 69 | 69 | ||
| 70 | +grpc.enterprise-resource-service.url=47.101.193.136 | ||
| 71 | +grpc.enterprise-resource-service.port=3028 | ||
| 72 | + | ||
| 70 | grpc.meizhongyihe-service.url=47.101.193.136 | 73 | grpc.meizhongyihe-service.url=47.101.193.136 |
| 71 | grpc.meizhongyihe-service.port=3040 | 74 | grpc.meizhongyihe-service.port=3040 |
| 72 | 75 | ... | ... |
-
Please register or login to post a comment