Showing
22 changed files
with
375 additions
and
26 deletions
| ... | @@ -8,6 +8,7 @@ import com.infoloop.tianting.WOperatorServiceProtoRpcGrpc; | ... | @@ -8,6 +8,7 @@ import com.infoloop.tianting.WOperatorServiceProtoRpcGrpc; |
| 8 | import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderServiceRpcGrpc; | 8 | import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderServiceRpcGrpc; |
| 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.clientresourcetagservice.ClientResourceTagServiceRpcGrpc; | ||
| 11 | import com.infoloop.tianting.deliveryruleservice.TiantingDeliveryRuleServiceRpcGrpc; | 12 | import com.infoloop.tianting.deliveryruleservice.TiantingDeliveryRuleServiceRpcGrpc; |
| 12 | import com.infoloop.tianting.enterpriseresourcetagservice.EnterpriseResourceTagServiceRpcGrpc; | 13 | import com.infoloop.tianting.enterpriseresourcetagservice.EnterpriseResourceTagServiceRpcGrpc; |
| 13 | import com.infoloop.tianting.menuservice.MenuServiceRpcGrpc; | 14 | import com.infoloop.tianting.menuservice.MenuServiceRpcGrpc; |
| ... | @@ -32,6 +33,9 @@ import static com.infoloop.tianting.constant.ConfigConstants.CLIENT_CUSTOMER_SER | ... | @@ -32,6 +33,9 @@ import static com.infoloop.tianting.constant.ConfigConstants.CLIENT_CUSTOMER_SER |
| 32 | import static com.infoloop.tianting.constant.ConfigConstants.CLIENT_INVENTORY_SERVICE_CHANNEL; | 33 | import static com.infoloop.tianting.constant.ConfigConstants.CLIENT_INVENTORY_SERVICE_CHANNEL; |
| 33 | import static com.infoloop.tianting.constant.ConfigConstants.CLIENT_INVENTORY_SERVICE_RPC_PORT; | 34 | import static com.infoloop.tianting.constant.ConfigConstants.CLIENT_INVENTORY_SERVICE_RPC_PORT; |
| 34 | import static com.infoloop.tianting.constant.ConfigConstants.CLIENT_INVENTORY_SERVICE_RPC_URL; | 35 | import static com.infoloop.tianting.constant.ConfigConstants.CLIENT_INVENTORY_SERVICE_RPC_URL; |
| 36 | +import static com.infoloop.tianting.constant.ConfigConstants.CLIENT_RESOURCE_SERVICE_CHANNEL; | ||
| 37 | +import static com.infoloop.tianting.constant.ConfigConstants.CLIENT_RESOURCE_SERVICE_RPC_PORT; | ||
| 38 | +import static com.infoloop.tianting.constant.ConfigConstants.CLIENT_RESOURCE_SERVICE_RPC_URL; | ||
| 35 | import static com.infoloop.tianting.constant.ConfigConstants.DELIVERY_SERVICE_CHANNEL; | 39 | import static com.infoloop.tianting.constant.ConfigConstants.DELIVERY_SERVICE_CHANNEL; |
| 36 | import static com.infoloop.tianting.constant.ConfigConstants.DELIVERY_SERVICE_RPC_PORT; | 40 | import static com.infoloop.tianting.constant.ConfigConstants.DELIVERY_SERVICE_RPC_PORT; |
| 37 | import static com.infoloop.tianting.constant.ConfigConstants.DELIVERY_SERVICE_RPC_URL; | 41 | import static com.infoloop.tianting.constant.ConfigConstants.DELIVERY_SERVICE_RPC_URL; |
| ... | @@ -268,4 +272,21 @@ public class GrpcConfig { | ... | @@ -268,4 +272,21 @@ public class GrpcConfig { |
| 268 | public MeiZhongYiHeServiceRpcGrpc.MeiZhongYiHeServiceRpcBlockingStub meiZhongYiHeServiceRpcBlockingStub(@Autowired @Qualifier(MEIZHONGYIHE_SERVICE_CHANNEL) final ManagedChannel channel) { | 272 | public MeiZhongYiHeServiceRpcGrpc.MeiZhongYiHeServiceRpcBlockingStub meiZhongYiHeServiceRpcBlockingStub(@Autowired @Qualifier(MEIZHONGYIHE_SERVICE_CHANNEL) final ManagedChannel channel) { |
| 269 | return MeiZhongYiHeServiceRpcGrpc.newBlockingStub(channel); | 273 | return MeiZhongYiHeServiceRpcGrpc.newBlockingStub(channel); |
| 270 | } | 274 | } |
| 275 | + | ||
| 276 | + @Bean(CLIENT_RESOURCE_SERVICE_CHANNEL) | ||
| 277 | + public ManagedChannel clientResourceServiceChannel(@Value(CLIENT_RESOURCE_SERVICE_RPC_URL) final String url, | ||
| 278 | + @Value(CLIENT_RESOURCE_SERVICE_RPC_PORT) final int port, | ||
| 279 | + @Autowired final ClientInterceptor clientInterceptor) { | ||
| 280 | + return NettyChannelBuilder.forAddress(url, port) | ||
| 281 | + .idleTimeout(DEFAULT_TIMEOUT_DAYS, TimeUnit.DAYS) | ||
| 282 | + .intercept(clientInterceptor) | ||
| 283 | + .usePlaintext() | ||
| 284 | + .maxInboundMessageSize(Integer.MAX_VALUE) | ||
| 285 | + .build(); | ||
| 286 | + } | ||
| 287 | + | ||
| 288 | + @Bean | ||
| 289 | + public ClientResourceTagServiceRpcGrpc.ClientResourceTagServiceRpcBlockingStub clientResourceTagServiceRpcBlockingStub(@Autowired @Qualifier(CLIENT_RESOURCE_SERVICE_CHANNEL) final ManagedChannel channel) { | ||
| 290 | + return ClientResourceTagServiceRpcGrpc.newBlockingStub(channel); | ||
| 291 | + } | ||
| 271 | } | 292 | } | ... | ... |
| ... | @@ -76,6 +76,10 @@ public interface ConfigConstants { | ... | @@ -76,6 +76,10 @@ public interface ConfigConstants { |
| 76 | String MEIZHONGYIHE_SERVICE_RPC_PORT = "${grpc.meizhongyihe-service.port}"; | 76 | String MEIZHONGYIHE_SERVICE_RPC_PORT = "${grpc.meizhongyihe-service.port}"; |
| 77 | String MEIZHONGYIHE_SERVICE_CHANNEL = "meizhongyihe-service-channel"; | 77 | String MEIZHONGYIHE_SERVICE_CHANNEL = "meizhongyihe-service-channel"; |
| 78 | 78 | ||
| 79 | + String CLIENT_RESOURCE_SERVICE_RPC_URL = "${grpc.client-resource-service.url}"; | ||
| 80 | + String CLIENT_RESOURCE_SERVICE_RPC_PORT = "${grpc.client-resource-service.port}"; | ||
| 81 | + String CLIENT_RESOURCE_SERVICE_CHANNEL = "client-resource-tag-service-channel"; | ||
| 82 | + | ||
| 79 | String ASYNC_EXECUTOR = "asyncExecutor"; | 83 | String ASYNC_EXECUTOR = "asyncExecutor"; |
| 80 | String SCHEDULED_TASK_EXECUTOR = "scheduledTaskExecutor"; | 84 | String SCHEDULED_TASK_EXECUTOR = "scheduledTaskExecutor"; |
| 81 | 85 | ... | ... |
| 1 | package com.infoloop.tianting.context; | 1 | package com.infoloop.tianting.context; |
| 2 | 2 | ||
| 3 | +import com.infoloop.tianting.enums.LoginSourceEnum; | ||
| 3 | import lombok.AllArgsConstructor; | 4 | import lombok.AllArgsConstructor; |
| 4 | import lombok.Builder; | 5 | import lombok.Builder; |
| 5 | import lombok.Data; | 6 | import lombok.Data; |
| ... | @@ -61,6 +62,8 @@ public class LoginContextHolder { | ... | @@ -61,6 +62,8 @@ public class LoginContextHolder { |
| 61 | @Builder.Default | 62 | @Builder.Default |
| 62 | private String openId = ""; | 63 | private String openId = ""; |
| 63 | 64 | ||
| 65 | + private LoginSourceEnum loginSource; | ||
| 66 | + | ||
| 64 | } | 67 | } |
| 65 | 68 | ||
| 66 | } | 69 | } | ... | ... |
| ... | @@ -14,10 +14,12 @@ import org.springframework.http.HttpStatus; | ... | @@ -14,10 +14,12 @@ import org.springframework.http.HttpStatus; |
| 14 | import org.springframework.validation.annotation.Validated; | 14 | import org.springframework.validation.annotation.Validated; |
| 15 | import org.springframework.web.bind.annotation.GetMapping; | 15 | import org.springframework.web.bind.annotation.GetMapping; |
| 16 | import org.springframework.web.bind.annotation.PathVariable; | 16 | import org.springframework.web.bind.annotation.PathVariable; |
| 17 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 17 | import org.springframework.web.bind.annotation.RequestParam; | 18 | import org.springframework.web.bind.annotation.RequestParam; |
| 18 | import org.springframework.web.bind.annotation.ResponseStatus; | 19 | import org.springframework.web.bind.annotation.ResponseStatus; |
| 19 | import org.springframework.web.bind.annotation.RestController; | 20 | import org.springframework.web.bind.annotation.RestController; |
| 20 | 21 | ||
| 22 | +import java.io.IOException; | ||
| 21 | import java.util.List; | 23 | import java.util.List; |
| 22 | 24 | ||
| 23 | @Api(tags = "ClientCustomer") | 25 | @Api(tags = "ClientCustomer") |
| ... | @@ -81,4 +83,11 @@ public class ClientCustomerController { | ... | @@ -81,4 +83,11 @@ public class ClientCustomerController { |
| 81 | return clientCustomerService.getTodayOrderStatisticForHis(customerToken); | 83 | return clientCustomerService.getTodayOrderStatisticForHis(customerToken); |
| 82 | } | 84 | } |
| 83 | 85 | ||
| 86 | + @ApiOperation(value = "同步his客户信息") | ||
| 87 | + @PostMapping("/hisclientcustomers/synchronization") | ||
| 88 | + @ResponseStatus(HttpStatus.OK) | ||
| 89 | + public void synchronizationHisClientCustomer() throws IOException { | ||
| 90 | + clientCustomerService.synchronizationHisClientCustomer(); | ||
| 91 | + } | ||
| 92 | + | ||
| 84 | } | 93 | } | ... | ... |
| ... | @@ -67,7 +67,6 @@ public class LoginInterceptor extends HandlerInterceptorAdapter { | ... | @@ -67,7 +67,6 @@ public class LoginInterceptor extends HandlerInterceptorAdapter { |
| 67 | StpUtil.checkLogin(); | 67 | StpUtil.checkLogin(); |
| 68 | final var enterpriseId = Convert.toInt(StpUtil.getExtra(CommonConstants.ENTERPRISE_ID)); | 68 | final var enterpriseId = Convert.toInt(StpUtil.getExtra(CommonConstants.ENTERPRISE_ID)); |
| 69 | final var loginSource = Convert.toInt(StpUtil.getExtra(CommonConstants.LOGIN_SOURCE)); | 69 | final var loginSource = Convert.toInt(StpUtil.getExtra(CommonConstants.LOGIN_SOURCE)); |
| 70 | - log.info("Login success, enterpriseId: {}, loginSource: {}", enterpriseId, loginSource); | ||
| 71 | if (loginSource.equals(LoginSourceEnum.CUSTOMER.getValue())) { | 70 | if (loginSource.equals(LoginSourceEnum.CUSTOMER.getValue())) { |
| 72 | final var openId = Convert.toStr(StpUtil.getExtra(CommonConstants.OPEN_ID)); | 71 | final var openId = Convert.toStr(StpUtil.getExtra(CommonConstants.OPEN_ID)); |
| 73 | final var loginId = StpUtil.getLoginIdAsInt(); | 72 | final var loginId = StpUtil.getLoginIdAsInt(); |
| ... | @@ -77,8 +76,7 @@ public class LoginInterceptor extends HandlerInterceptorAdapter { | ... | @@ -77,8 +76,7 @@ public class LoginInterceptor extends HandlerInterceptorAdapter { |
| 77 | ResponseUtil.write(response, ResponseResult.failed(ErrorCodeEnum.VALIDATE_FAILED)); | 76 | ResponseUtil.write(response, ResponseResult.failed(ErrorCodeEnum.VALIDATE_FAILED)); |
| 78 | return false; | 77 | return false; |
| 79 | } | 78 | } |
| 80 | - log.info("Customer login success, customerId: {}, enterpriseId: {}, openId:{}", loginId, enterpriseId, openId); | 79 | + builder.id(loginId).enterpriseId(enterpriseId).name(customer.getResponse().getName()).openId(openId).loginSource(LoginSourceEnum.CUSTOMER); |
| 81 | - builder.id(loginId).enterpriseId(enterpriseId).name(customer.getResponse().getName()).openId(openId); | ||
| 82 | return true; | 80 | return true; |
| 83 | } else if (loginSource.equals(LoginSourceEnum.OPERATOR.getValue())){ | 81 | } else if (loginSource.equals(LoginSourceEnum.OPERATOR.getValue())){ |
| 84 | final var loginId = StpUtil.getLoginIdAsInt(); | 82 | final var loginId = StpUtil.getLoginIdAsInt(); |
| ... | @@ -88,20 +86,19 @@ public class LoginInterceptor extends HandlerInterceptorAdapter { | ... | @@ -88,20 +86,19 @@ public class LoginInterceptor extends HandlerInterceptorAdapter { |
| 88 | ResponseUtil.write(response, ResponseResult.failed(ErrorCodeEnum.VALIDATE_FAILED)); | 86 | ResponseUtil.write(response, ResponseResult.failed(ErrorCodeEnum.VALIDATE_FAILED)); |
| 89 | return false; | 87 | return false; |
| 90 | } | 88 | } |
| 91 | - builder.id(loginId).enterpriseId(enterpriseId).name(opeartor.getName()); | 89 | + builder.id(loginId).enterpriseId(enterpriseId).name(opeartor.getName()).loginSource(LoginSourceEnum.OPERATOR); |
| 92 | return true; | 90 | return true; |
| 93 | - | ||
| 94 | } else if (loginSource.equals(LoginSourceEnum.KDS.getValue())) { | 91 | } else if (loginSource.equals(LoginSourceEnum.KDS.getValue())) { |
| 95 | final var loginId = StpUtil.getLoginIdAsInt(); | 92 | final var loginId = StpUtil.getLoginIdAsInt(); |
| 96 | final var operator = wOperatorServiceRpcClient.getWOperatorById(loginId).getResponse(); | 93 | final var operator = wOperatorServiceRpcClient.getWOperatorById(loginId).getResponse(); |
| 97 | if (operator.getId() == 0) { | 94 | if (operator.getId() == 0) { |
| 98 | throw ClientEndExceptions.AuthenticationFailure.build(ErrorCodeEnum.UNAUTHORIZED.name()); | 95 | throw ClientEndExceptions.AuthenticationFailure.build(ErrorCodeEnum.UNAUTHORIZED.name()); |
| 99 | } | 96 | } |
| 100 | - builder.id(loginId).enterpriseId(enterpriseId).name(operator.getName()); | 97 | + builder.id(loginId).enterpriseId(enterpriseId).name(operator.getName()).loginSource(LoginSourceEnum.KDS); |
| 101 | return true; | 98 | return true; |
| 102 | } else { | 99 | } else { |
| 103 | final var loginId = StpUtil.getLoginIdAsString(); | 100 | final var loginId = StpUtil.getLoginIdAsString(); |
| 104 | - builder.openId(loginId).enterpriseId(enterpriseId); | 101 | + builder.openId(loginId).enterpriseId(enterpriseId).loginSource(LoginSourceEnum.MINI_PROGRAM); |
| 105 | return true; | 102 | return true; |
| 106 | } | 103 | } |
| 107 | } | 104 | } | ... | ... |
| 1 | package com.infoloop.tianting.intercepter; | 1 | package com.infoloop.tianting.intercepter; |
| 2 | 2 | ||
| 3 | -import cn.dev33.satoken.stp.StpUtil; | ||
| 4 | -import cn.hutool.core.convert.Convert; | ||
| 5 | import com.infoloop.tianting.constant.CommonConstants; | 3 | import com.infoloop.tianting.constant.CommonConstants; |
| 6 | -import com.infoloop.tianting.enums.LoginSourceEnum; | ||
| 7 | import org.springframework.http.server.ServerHttpRequest; | 4 | import org.springframework.http.server.ServerHttpRequest; |
| 8 | import org.springframework.http.server.ServerHttpResponse; | 5 | import org.springframework.http.server.ServerHttpResponse; |
| 9 | -import org.springframework.util.StringUtils; | 6 | +import org.springframework.http.server.ServletServerHttpRequest; |
| 10 | import org.springframework.web.socket.WebSocketHandler; | 7 | import org.springframework.web.socket.WebSocketHandler; |
| 11 | import org.springframework.web.socket.server.HandshakeInterceptor; | 8 | import org.springframework.web.socket.server.HandshakeInterceptor; |
| 12 | 9 | ||
| ... | @@ -17,16 +14,16 @@ public class WebSocketHandshakeInterceptor implements HandshakeInterceptor { | ... | @@ -17,16 +14,16 @@ public class WebSocketHandshakeInterceptor implements HandshakeInterceptor { |
| 17 | 14 | ||
| 18 | @Override | 15 | @Override |
| 19 | public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map<String, Object> attributes) { | 16 | public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map<String, Object> attributes) { |
| 20 | - final var authorization = request.getHeaders().getFirst(CommonConstants.AUTHORIZATION); | 17 | + if (request instanceof ServletServerHttpRequest) { |
| 21 | - if (StringUtils.isEmpty(authorization)) { | 18 | + ServletServerHttpRequest servletRequest = (ServletServerHttpRequest) request; |
| 22 | - return false; | 19 | + String userType = servletRequest.getServletRequest().getParameter(CommonConstants.USER_TYPE); |
| 23 | - } | 20 | + String userId = servletRequest.getServletRequest().getParameter(CommonConstants.USER_ID); |
| 24 | - final var loginSource = Convert.toInt(StpUtil.getExtra(CommonConstants.LOGIN_SOURCE)); | 21 | + attributes.put(CommonConstants.USER_TYPE, userType); |
| 25 | - final var loginSourceEnum = LoginSourceEnum.getByValue(loginSource); | 22 | + attributes.put(CommonConstants.USER_ID, userId); |
| 26 | - attributes.put(CommonConstants.USER_TYPE, loginSourceEnum.getUserType().name()); | ||
| 27 | - attributes.put(CommonConstants.USER_ID, StpUtil.getLoginIdAsString()); | ||
| 28 | return true; | 23 | return true; |
| 29 | } | 24 | } |
| 25 | + return false; | ||
| 26 | + } | ||
| 30 | 27 | ||
| 31 | @Override | 28 | @Override |
| 32 | public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Exception exception) { | 29 | public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Exception exception) { | ... | ... |
| 1 | +package com.infoloop.tianting.logic.async; | ||
| 2 | + | ||
| 3 | +import com.infoloop.rpc.meizhongyiheservice.Customer; | ||
| 4 | +import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderModification; | ||
| 5 | +import com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum; | ||
| 6 | +import com.infoloop.tianting.clientcustomerservice.SingleClientCustomerRpcResponse; | ||
| 7 | +import com.infoloop.tianting.clientinventoryservice.SingleClientRpcResponse; | ||
| 8 | +import com.infoloop.tianting.context.LoginContextHolder; | ||
| 9 | +import com.infoloop.tianting.model.dto.OrderDbDTO; | ||
| 10 | +import com.infoloop.tianting.server.WebSocketServer; | ||
| 11 | +import com.infoloop.tianting.server.message.MessageTypeEnum; | ||
| 12 | +import com.infoloop.tianting.server.message.NoticeTypeEnum; | ||
| 13 | +import com.infoloop.tianting.server.message.SocketMessage; | ||
| 14 | +import com.infoloop.tianting.server.message.data.CustomerAlterRoomNoData; | ||
| 15 | +import com.infoloop.tianting.server.session.UserSessionKey; | ||
| 16 | +import com.infoloop.tianting.server.session.UserTypeEnum; | ||
| 17 | +import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient; | ||
| 18 | +import com.infoloop.tianting.service.client.ClientResourceTagServiceRpcClient; | ||
| 19 | +import com.infoloop.tianting.service.client.InventoryServiceRpcClient; | ||
| 20 | +import com.infoloop.tianting.service.client.MeiZhongYiHeServiceClient; | ||
| 21 | +import com.infoloop.tianting.service.client.OperatorServiceRpcClient; | ||
| 22 | +import com.infoloop.tianting.service.client.OrderServiceRpcClient; | ||
| 23 | +import lombok.RequiredArgsConstructor; | ||
| 24 | +import lombok.extern.slf4j.Slf4j; | ||
| 25 | +import org.springframework.scheduling.annotation.Async; | ||
| 26 | +import org.springframework.stereotype.Component; | ||
| 27 | + | ||
| 28 | +import java.io.IOException; | ||
| 29 | +import java.util.List; | ||
| 30 | +import java.util.Objects; | ||
| 31 | +import java.util.function.Function; | ||
| 32 | +import java.util.stream.Collectors; | ||
| 33 | + | ||
| 34 | +import static com.infoloop.tianting.constant.ConfigConstants.ASYNC_EXECUTOR; | ||
| 35 | + | ||
| 36 | +@Slf4j | ||
| 37 | +@Component | ||
| 38 | +@RequiredArgsConstructor | ||
| 39 | +public class HisCustomerRoomNoTask { | ||
| 40 | + | ||
| 41 | + private final OperatorServiceRpcClient operatorServiceRpcClient; | ||
| 42 | + | ||
| 43 | + private final ClientResourceTagServiceRpcClient clientResourceTagServiceRpcClient; | ||
| 44 | + | ||
| 45 | + private final InventoryServiceRpcClient inventoryServiceRpcClient; | ||
| 46 | + | ||
| 47 | + private final MeiZhongYiHeServiceClient meiZhongYiHeServiceClient; | ||
| 48 | + | ||
| 49 | + private final OrderServiceRpcClient orderServiceRpcClient; | ||
| 50 | + | ||
| 51 | + private final ClientCustomerServiceRpcClient clientCustomerServiceRpcClient; | ||
| 52 | + | ||
| 53 | + @Async(ASYNC_EXECUTOR) | ||
| 54 | + public void synchronization(LoginContextHolder.LoginInfo loginInfo) throws IOException { | ||
| 55 | + final var cOperatorById = operatorServiceRpcClient.getCOperatorById(loginInfo.getId()); | ||
| 56 | + | ||
| 57 | + final var stallIdsList = clientResourceTagServiceRpcClient | ||
| 58 | + .getUserResources(cOperatorById.getEnterpriseId(), cOperatorById.getClientId(), cOperatorById.getId()) | ||
| 59 | + .getStallIdsList(); | ||
| 60 | + | ||
| 61 | + final var stalls = inventoryServiceRpcClient | ||
| 62 | + .getStallsByIds(cOperatorById.getEnterpriseId(), stallIdsList) | ||
| 63 | + .getClientsList(); | ||
| 64 | + | ||
| 65 | + final var stallCodes = stalls.stream() | ||
| 66 | + .filter(e -> !e.getIsDelivery()) | ||
| 67 | + .map(SingleClientRpcResponse::getCode) | ||
| 68 | + .collect(Collectors.toList()); | ||
| 69 | + | ||
| 70 | + final var customersList = meiZhongYiHeServiceClient.getCustomersByCondition(stallCodes); | ||
| 71 | + final var hisCustomerIds = customersList.stream().map(Customer::getCustomerId).collect(Collectors.toList()); | ||
| 72 | + | ||
| 73 | + final var customerMap = customersList.stream() | ||
| 74 | + .collect(Collectors.toMap(Customer::getCustomerId, Function.identity(), (a, b) -> a)); | ||
| 75 | + | ||
| 76 | + final var queryOrderDto = OrderDbDTO.QueryOrderByConditionDto.builder() | ||
| 77 | + .shouldFilterStallIds(true) | ||
| 78 | + .stallIds(stallIdsList) | ||
| 79 | + .shouldFilterStatues(true) | ||
| 80 | + .statues(List.of(OrderStatusEnum.TO_PREPARE, OrderStatusEnum.PREPARING)) | ||
| 81 | + .build(); | ||
| 82 | + | ||
| 83 | + final var orders = orderServiceRpcClient.getOrdersByCondition(queryOrderDto); | ||
| 84 | + | ||
| 85 | + final var clientCustomerMap = clientCustomerServiceRpcClient.getClientCustomersByHISCustomerIds(hisCustomerIds) | ||
| 86 | + .getResponsesList() | ||
| 87 | + .stream() | ||
| 88 | + .collect(Collectors.toMap(SingleClientCustomerRpcResponse::getId, Function.identity(), (a, b) -> a)); | ||
| 89 | + | ||
| 90 | + final var alterRoomNoCustomers = orders.stream() | ||
| 91 | + .map(order -> { | ||
| 92 | + final var singleClientCustomerRpcResponse = clientCustomerMap.get(order.getCustomerId()); | ||
| 93 | + if (singleClientCustomerRpcResponse == null) { | ||
| 94 | + return null; | ||
| 95 | + } | ||
| 96 | + final var customer = customerMap.get(singleClientCustomerRpcResponse.getHISCustomerId()); | ||
| 97 | + if (customer == null) { | ||
| 98 | + log.error("customer is null for HIS customerId: {}", singleClientCustomerRpcResponse.getHISCustomerId()); | ||
| 99 | + return null; | ||
| 100 | + } | ||
| 101 | + final var syncRoomNo = customer.getCustomerHospitalRecord().getRoomNo(); | ||
| 102 | + if (!syncRoomNo.equals(order.getRoomNo())) { | ||
| 103 | + return CustomerAlterRoomNoData.AlterRoomNoCustomer.builder() | ||
| 104 | + .orderId(order.getId()) | ||
| 105 | + .customerId(singleClientCustomerRpcResponse.getId()) | ||
| 106 | + .roomNo(order.getRoomNo()) | ||
| 107 | + .alterRoomNo(syncRoomNo) | ||
| 108 | + .build(); | ||
| 109 | + } | ||
| 110 | + return null; | ||
| 111 | + }) | ||
| 112 | + .filter(Objects::nonNull) | ||
| 113 | + .collect(Collectors.toList()); | ||
| 114 | + | ||
| 115 | + // 记录找不到 HIS 客户 ID 的错误日志 | ||
| 116 | + final var missingCustomerIds = orders.stream() | ||
| 117 | + .map(order -> clientCustomerMap.get(order.getCustomerId())) | ||
| 118 | + .filter(Objects::nonNull) | ||
| 119 | + .map(SingleClientCustomerRpcResponse::getHISCustomerId) | ||
| 120 | + .filter(hisId -> !customerMap.containsKey(hisId)) | ||
| 121 | + .collect(Collectors.toList()); | ||
| 122 | + | ||
| 123 | + if (!missingCustomerIds.isEmpty()) { | ||
| 124 | + log.error("customer is null for HIS customerIds: {}", missingCustomerIds); | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + if (alterRoomNoCustomers.isEmpty()) { | ||
| 128 | + return; | ||
| 129 | + } | ||
| 130 | + | ||
| 131 | + final var isUpdated = orderServiceRpcClient.batchUpdateClientCustomerOrders( | ||
| 132 | + loginInfo, | ||
| 133 | + alterRoomNoCustomers.stream() | ||
| 134 | + .map(e -> ClientCustomerOrderModification.newBuilder() | ||
| 135 | + .setId(e.getOrderId()) | ||
| 136 | + .setShouldUpdateSyncRoomNo(true) | ||
| 137 | + .setSyncRoomNo(e.getAlterRoomNo()) | ||
| 138 | + .build()) | ||
| 139 | + .collect(Collectors.toList())); | ||
| 140 | + | ||
| 141 | + if (!isUpdated) { | ||
| 142 | + log.error("OrderServiceRpcClient.batchUpdateClientCustomerOrders error"); | ||
| 143 | + return; | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + final var affectedCustomers = alterRoomNoCustomers.stream() | ||
| 147 | + .map(CustomerAlterRoomNoData.AlterRoomNoCustomer::getCustomerId) | ||
| 148 | + .distinct() | ||
| 149 | + .count(); | ||
| 150 | + | ||
| 151 | + final var data = SocketMessage.<CustomerAlterRoomNoData>builder() | ||
| 152 | + .type(MessageTypeEnum.CUSTOMER) | ||
| 153 | + .noticeType(NoticeTypeEnum.CUSTOMER_ALTER_ROOM_NO) | ||
| 154 | + .subject(NoticeTypeEnum.CUSTOMER_ALTER_ROOM_NO.getDescription()) | ||
| 155 | + .message("有" + affectedCustomers + " 个客户房间号发生了变更,系统已显示最新房间号。") | ||
| 156 | + .data(CustomerAlterRoomNoData.builder().alterRoomNoCustomers(alterRoomNoCustomers).build()) | ||
| 157 | + .build(); | ||
| 158 | + | ||
| 159 | + WebSocketServer.sendMessageToUser( | ||
| 160 | + UserSessionKey.builder() | ||
| 161 | + .userId(String.valueOf(loginInfo.getId())) | ||
| 162 | + .userType(UserTypeEnum.CLIENT) | ||
| 163 | + .build(), | ||
| 164 | + data | ||
| 165 | + ); | ||
| 166 | + } | ||
| 167 | +} |
| ... | @@ -123,6 +123,10 @@ public class OrderDbDTO { | ... | @@ -123,6 +123,10 @@ public class OrderDbDTO { |
| 123 | private Boolean shouldFilterPayStatus = false; | 123 | private Boolean shouldFilterPayStatus = false; |
| 124 | @Builder.Default | 124 | @Builder.Default |
| 125 | private PayStatusEnum payStatus = PayStatusEnum.UNKNOWN_PAY_STATUS; | 125 | private PayStatusEnum payStatus = PayStatusEnum.UNKNOWN_PAY_STATUS; |
| 126 | + @Builder.Default | ||
| 127 | + private Boolean shouldFilterStatues = false; | ||
| 128 | + @Builder.Default | ||
| 129 | + private List<OrderStatusEnum> statues = new ArrayList<>(); | ||
| 126 | } | 130 | } |
| 127 | 131 | ||
| 128 | @Data | 132 | @Data | ... | ... |
| ... | @@ -80,6 +80,14 @@ public class WebSocketServer extends TextWebSocketHandler { | ... | @@ -80,6 +80,14 @@ public class WebSocketServer extends TextWebSocketHandler { |
| 80 | sendMessageToUsers(keys, socketMessage); | 80 | sendMessageToUsers(keys, socketMessage); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | + public static <T> void sendMessageByUserTypes(List<UserTypeEnum> userTypes, List<String> authUserIds, SocketMessage<T> socketMessage) throws IOException { | ||
| 84 | + final var keys = userSessions.keySet().stream() | ||
| 85 | + .filter(userSessionData -> userTypes.contains(userSessionData.getUserType())) | ||
| 86 | + .filter(userSessionData -> authUserIds.contains(userSessionData.getUserId())) | ||
| 87 | + .collect(Collectors.toList()); | ||
| 88 | + sendMessageToUsers(keys, socketMessage); | ||
| 89 | + } | ||
| 90 | + | ||
| 83 | public static void closeConnection(UserSessionKey key) { | 91 | public static void closeConnection(UserSessionKey key) { |
| 84 | final var userData = userSessions.get(key); | 92 | final var userData = userSessions.get(key); |
| 85 | if (userData != null) { | 93 | if (userData != null) { | ... | ... |
| ... | @@ -5,7 +5,8 @@ import lombok.Getter; | ... | @@ -5,7 +5,8 @@ import lombok.Getter; |
| 5 | @Getter | 5 | @Getter |
| 6 | public enum MessageTypeEnum { | 6 | public enum MessageTypeEnum { |
| 7 | 7 | ||
| 8 | - ORDER("订单类型消息"); | 8 | + ORDER("订单类型消息"), |
| 9 | + CUSTOMER("客户类型消息");; | ||
| 9 | 10 | ||
| 10 | private final String description; | 11 | private final String description; |
| 11 | 12 | ... | ... |
| ... | @@ -5,8 +5,10 @@ import lombok.Getter; | ... | @@ -5,8 +5,10 @@ import lombok.Getter; |
| 5 | @Getter | 5 | @Getter |
| 6 | public enum NoticeTypeEnum { | 6 | public enum NoticeTypeEnum { |
| 7 | ORDER_CREATED("下单成功", MessageTypeEnum.ORDER), | 7 | ORDER_CREATED("下单成功", MessageTypeEnum.ORDER), |
| 8 | - ORDER_PAYMENT_SUCCESS("支付成功", MessageTypeEnum.ORDER); | 8 | + ORDER_PAYMENT_SUCCESS("支付成功", MessageTypeEnum.ORDER), |
| 9 | + CUSTOMER_ALTER_ROOM_NO("客户变更房间号", MessageTypeEnum.CUSTOMER), | ||
| 9 | 10 | ||
| 11 | + ; | ||
| 10 | private final String description; | 12 | private final String description; |
| 11 | 13 | ||
| 12 | private final MessageTypeEnum messageType; | 14 | private final MessageTypeEnum messageType; | ... | ... |
| 1 | +package com.infoloop.tianting.server.message.data; | ||
| 2 | + | ||
| 3 | +import lombok.Builder; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +import java.util.List; | ||
| 7 | + | ||
| 8 | +@Data | ||
| 9 | +@Builder | ||
| 10 | +public class CustomerAlterRoomNoData { | ||
| 11 | + | ||
| 12 | + private List<AlterRoomNoCustomer> alterRoomNoCustomers; | ||
| 13 | + | ||
| 14 | + @Data | ||
| 15 | + @Builder | ||
| 16 | + public static class AlterRoomNoCustomer { | ||
| 17 | + | ||
| 18 | + private int orderId; | ||
| 19 | + | ||
| 20 | + private int customerId; | ||
| 21 | + | ||
| 22 | + private String roomNo; | ||
| 23 | + | ||
| 24 | + private String alterRoomNo; | ||
| 25 | + } | ||
| 26 | +} |
| ... | @@ -9,6 +9,7 @@ import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchDeleteCustomerLabelRe | ... | @@ -9,6 +9,7 @@ import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchDeleteCustomerLabelRe |
| 9 | import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchDeleteCustomerLabelRefResponseDto; | 9 | import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchDeleteCustomerLabelRefResponseDto; |
| 10 | import com.infoloop.tianting.model.dto.ClientLabelDTO.CustomerLabelRefDetailDto; | 10 | import com.infoloop.tianting.model.dto.ClientLabelDTO.CustomerLabelRefDetailDto; |
| 11 | 11 | ||
| 12 | +import java.io.IOException; | ||
| 12 | import java.util.List; | 13 | import java.util.List; |
| 13 | 14 | ||
| 14 | public interface ClientCustomerService { | 15 | public interface ClientCustomerService { |
| ... | @@ -36,4 +37,6 @@ public interface ClientCustomerService { | ... | @@ -36,4 +37,6 @@ public interface ClientCustomerService { |
| 36 | TodayOrderDto getTodayOrderStatisticForHis(String token); | 37 | TodayOrderDto getTodayOrderStatisticForHis(String token); |
| 37 | 38 | ||
| 38 | ClientCustomerDto getClientCustomerByHISCustomerNo(String hisCustomerNo); | 39 | ClientCustomerDto getClientCustomerByHISCustomerNo(String hisCustomerNo); |
| 40 | + | ||
| 41 | + void synchronizationHisClientCustomer() throws IOException; | ||
| 39 | } | 42 | } | ... | ... |
| ... | @@ -2,7 +2,11 @@ package com.infoloop.tianting.service.client; | ... | @@ -2,7 +2,11 @@ package com.infoloop.tianting.service.client; |
| 2 | 2 | ||
| 3 | import com.infoloop.tianting.clientcustomerservice.BatchCreateClientCustomerLabelRefsRpcRequest; | 3 | import com.infoloop.tianting.clientcustomerservice.BatchCreateClientCustomerLabelRefsRpcRequest; |
| 4 | import com.infoloop.tianting.clientcustomerservice.BatchCreateClientCustomerLabelRefsRpcResponse; | 4 | import com.infoloop.tianting.clientcustomerservice.BatchCreateClientCustomerLabelRefsRpcResponse; |
| 5 | +import com.infoloop.tianting.clientcustomerservice.BatchCreateClientCustomerOperationRecordsRpcRequest; | ||
| 6 | +import com.infoloop.tianting.clientcustomerservice.BatchUpdateClientCustomersRpcRequest; | ||
| 5 | import com.infoloop.tianting.clientcustomerservice.ClientCustomerLabelRefCreation; | 7 | import com.infoloop.tianting.clientcustomerservice.ClientCustomerLabelRefCreation; |
| 8 | +import com.infoloop.tianting.clientcustomerservice.ClientCustomerModification; | ||
| 9 | +import com.infoloop.tianting.clientcustomerservice.ClientCustomerOperationRecordCreation; | ||
| 6 | import com.infoloop.tianting.clientcustomerservice.ClientCustomerServiceRpcGrpc; | 10 | import com.infoloop.tianting.clientcustomerservice.ClientCustomerServiceRpcGrpc; |
| 7 | import com.infoloop.tianting.clientcustomerservice.DeleteClientCustomerLabelRefsByIdsRpcRequest; | 11 | import com.infoloop.tianting.clientcustomerservice.DeleteClientCustomerLabelRefsByIdsRpcRequest; |
| 8 | import com.infoloop.tianting.clientcustomerservice.DeleteClientCustomerLabelRefsRpcResponse; | 12 | import com.infoloop.tianting.clientcustomerservice.DeleteClientCustomerLabelRefsRpcResponse; |
| ... | @@ -24,6 +28,7 @@ import com.infoloop.tianting.clientcustomerservice.GetClientCustomersByIdsRpcReq | ... | @@ -24,6 +28,7 @@ import com.infoloop.tianting.clientcustomerservice.GetClientCustomersByIdsRpcReq |
| 24 | import com.infoloop.tianting.clientcustomerservice.GetClientCustomersByIdsRpcResponse; | 28 | import com.infoloop.tianting.clientcustomerservice.GetClientCustomersByIdsRpcResponse; |
| 25 | import com.infoloop.tianting.clientcustomerservice.QueryClientCustomerLabelRefsByConditionRpcRequest; | 29 | import com.infoloop.tianting.clientcustomerservice.QueryClientCustomerLabelRefsByConditionRpcRequest; |
| 26 | import com.infoloop.tianting.clientcustomerservice.QueryClientCustomerLabelRefsByConditionRpcResponse; | 30 | import com.infoloop.tianting.clientcustomerservice.QueryClientCustomerLabelRefsByConditionRpcResponse; |
| 31 | +import com.infoloop.tianting.context.LoginContextHolder; | ||
| 27 | import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchCreateCustomerLabelRefDto; | 32 | import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchCreateCustomerLabelRefDto; |
| 28 | import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchDeleteCustomerLabelRefRequestDto; | 33 | import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchDeleteCustomerLabelRefRequestDto; |
| 29 | import lombok.RequiredArgsConstructor; | 34 | import lombok.RequiredArgsConstructor; |
| ... | @@ -145,4 +150,24 @@ public class ClientCustomerServiceRpcClient { | ... | @@ -145,4 +150,24 @@ public class ClientCustomerServiceRpcClient { |
| 145 | .build(); | 150 | .build(); |
| 146 | return clientCustomerServiceRpcBlockingStub.deleteClientCustomerLabelRefsByIds(request); | 151 | return clientCustomerServiceRpcBlockingStub.deleteClientCustomerLabelRefsByIds(request); |
| 147 | } | 152 | } |
| 153 | + | ||
| 154 | + public boolean batchUpdateClientCustomers(LoginContextHolder.LoginInfo loginInfo, List<ClientCustomerModification> modifications) { | ||
| 155 | + final var request = BatchUpdateClientCustomersRpcRequest.newBuilder() | ||
| 156 | + .setEnterpriseId(loginInfo.getEnterpriseId()) | ||
| 157 | + .setUpdatedBy(loginInfo.getId()) | ||
| 158 | + .setUpdateSource(loginInfo.getLoginSource().getValue()) | ||
| 159 | + .addAllModifications(modifications) | ||
| 160 | + .build(); | ||
| 161 | + return clientCustomerServiceRpcBlockingStub.batchUpdateClientCustomers(request).getIsUpdated(); | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + public boolean batchCreateClientCustomerOperationRecords(LoginContextHolder.LoginInfo loginInfo, List<ClientCustomerOperationRecordCreation> creations) { | ||
| 165 | + final var request = BatchCreateClientCustomerOperationRecordsRpcRequest.newBuilder() | ||
| 166 | + .setEnterpriseId(loginInfo.getEnterpriseId()) | ||
| 167 | + .setCreatedBy(loginInfo.getId()) | ||
| 168 | + .setCreationSource(loginInfo.getLoginSource().getValue()) | ||
| 169 | + .addAllCreations(creations) | ||
| 170 | + .build(); | ||
| 171 | + return clientCustomerServiceRpcBlockingStub.batchCreateClientCustomerOperationRecords(request).getIsCreated(); | ||
| 172 | + } | ||
| 148 | } | 173 | } | ... | ... |
src/main/java/com/infoloop/tianting/service/client/ClientResourceTagServiceRpcClient.java
0 → 100644
| 1 | +package com.infoloop.tianting.service.client; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.clientresourcetagservice.ClientResourceTagServiceRpcGrpc; | ||
| 4 | +import com.infoloop.tianting.clientresourcetagservice.ResourceOperatorIdsGetByStallIdsRequest; | ||
| 5 | +import com.infoloop.tianting.clientresourcetagservice.SingleResourceLabelEntityRefsResponse; | ||
| 6 | +import com.infoloop.tianting.clientresourcetagservice.UserTagsAndResourcesGetRequest; | ||
| 7 | +import com.infoloop.tianting.clientresourcetagservice.UserTagsAndResourcesGetResponse; | ||
| 8 | +import lombok.RequiredArgsConstructor; | ||
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | +import org.springframework.stereotype.Service; | ||
| 11 | + | ||
| 12 | +import java.util.List; | ||
| 13 | + | ||
| 14 | +@Service | ||
| 15 | +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) | ||
| 16 | +public class ClientResourceTagServiceRpcClient { | ||
| 17 | + | ||
| 18 | + private final ClientResourceTagServiceRpcGrpc.ClientResourceTagServiceRpcBlockingStub clientResourceTagServiceRpcBlockingStub; | ||
| 19 | + | ||
| 20 | + public List<SingleResourceLabelEntityRefsResponse> getOperatorIdsByStallIds(List<Integer> stallIds) { | ||
| 21 | + return clientResourceTagServiceRpcBlockingStub.getOperatorIdsByStallIds(ResourceOperatorIdsGetByStallIdsRequest.newBuilder() | ||
| 22 | + .addAllStallIds(stallIds) | ||
| 23 | + .build()).getLabelEntityRefsList(); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + public UserTagsAndResourcesGetResponse getUserResources(int enterpriseId, int clientId, int operatorId) { | ||
| 27 | + return clientResourceTagServiceRpcBlockingStub.getUserResources(UserTagsAndResourcesGetRequest.newBuilder() | ||
| 28 | + .setEnterpriseId(enterpriseId) | ||
| 29 | + .setUserId(operatorId) | ||
| 30 | + .setClientId(clientId) | ||
| 31 | + .build()); | ||
| 32 | + } | ||
| 33 | +} |
| ... | @@ -6,6 +6,7 @@ import com.infoloop.rpc.meizhongyiheservice.GetCustomerAllergiesByCustomerIdsRpc | ... | @@ -6,6 +6,7 @@ import com.infoloop.rpc.meizhongyiheservice.GetCustomerAllergiesByCustomerIdsRpc |
| 6 | import com.infoloop.rpc.meizhongyiheservice.GetCustomerDetailByIdRpcRequest; | 6 | import com.infoloop.rpc.meizhongyiheservice.GetCustomerDetailByIdRpcRequest; |
| 7 | import com.infoloop.rpc.meizhongyiheservice.GetCustomerMedicalAdvicesByHospitalRecordIdsRpcRequest; | 7 | import com.infoloop.rpc.meizhongyiheservice.GetCustomerMedicalAdvicesByHospitalRecordIdsRpcRequest; |
| 8 | import com.infoloop.rpc.meizhongyiheservice.GetCustomerMedicalAdvicesByHospitalRecordIdsRpcResponse; | 8 | import com.infoloop.rpc.meizhongyiheservice.GetCustomerMedicalAdvicesByHospitalRecordIdsRpcResponse; |
| 9 | +import com.infoloop.rpc.meizhongyiheservice.GetCustomersByConditionRpcRequest; | ||
| 9 | import com.infoloop.rpc.meizhongyiheservice.MeiZhongYiHeServiceRpcGrpc; | 10 | import com.infoloop.rpc.meizhongyiheservice.MeiZhongYiHeServiceRpcGrpc; |
| 10 | import lombok.RequiredArgsConstructor; | 11 | import lombok.RequiredArgsConstructor; |
| 11 | import org.springframework.beans.factory.annotation.Autowired; | 12 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | @@ -44,4 +45,11 @@ public class MeiZhongYiHeServiceClient { | ... | @@ -44,4 +45,11 @@ public class MeiZhongYiHeServiceClient { |
| 44 | } | 45 | } |
| 45 | return customer.getCustomer(); | 46 | return customer.getCustomer(); |
| 46 | } | 47 | } |
| 48 | + | ||
| 49 | + public List<Customer> getCustomersByCondition(List<String> stallCodes) { | ||
| 50 | + final var request = GetCustomersByConditionRpcRequest.newBuilder() | ||
| 51 | + .addAllDeptCode(stallCodes) | ||
| 52 | + .build(); | ||
| 53 | + return meiZhongYiHeServiceRpcBlockingStub.getCustomersByCondition(request).getCustomersList(); | ||
| 54 | + } | ||
| 47 | } | 55 | } | ... | ... |
| ... | @@ -21,7 +21,7 @@ public class OperatorServiceRpcClient { | ... | @@ -21,7 +21,7 @@ public class OperatorServiceRpcClient { |
| 21 | return cOperatorServiceProtoRpcBlockingStub.getCOperatorByMobileOrEmail(request).getResponse(); | 21 | return cOperatorServiceProtoRpcBlockingStub.getCOperatorByMobileOrEmail(request).getResponse(); |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | - public SingleCOperatorRpcResponse getCOperatorById(Integer id) { | 24 | + public SingleCOperatorRpcResponse getCOperatorById(int id) { |
| 25 | final var request = GetCOperatorByIdRpcRequest.newBuilder().setId(id).build(); | 25 | final var request = GetCOperatorByIdRpcRequest.newBuilder().setId(id).build(); |
| 26 | return cOperatorServiceProtoRpcBlockingStub.getCOperatorById(request).getResponse(); | 26 | return cOperatorServiceProtoRpcBlockingStub.getCOperatorById(request).getResponse(); |
| 27 | } | 27 | } | ... | ... |
| ... | @@ -9,6 +9,7 @@ import com.infoloop.tianting.clientcustomerorderservice.BatchCreateOrderOperatio | ... | @@ -9,6 +9,7 @@ import com.infoloop.tianting.clientcustomerorderservice.BatchCreateOrderOperatio |
| 9 | import com.infoloop.tianting.clientcustomerorderservice.BatchSaveSkuSellQuantitiesRpcRequest; | 9 | import com.infoloop.tianting.clientcustomerorderservice.BatchSaveSkuSellQuantitiesRpcRequest; |
| 10 | import com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrderDetailsRpcRequest; | 10 | import com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrderDetailsRpcRequest; |
| 11 | import com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrderDetailsRpcResponse; | 11 | import com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrderDetailsRpcResponse; |
| 12 | +import com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrdersRpcRequest; | ||
| 12 | import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderCreation; | 13 | import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderCreation; |
| 13 | import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderDetailCreation; | 14 | import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderDetailCreation; |
| 14 | import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderDetailModification; | 15 | import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderDetailModification; |
| ... | @@ -43,6 +44,7 @@ import com.infoloop.tianting.clientcustomerorderservice.SkuSellQuantity; | ... | @@ -43,6 +44,7 @@ import com.infoloop.tianting.clientcustomerorderservice.SkuSellQuantity; |
| 43 | import com.infoloop.tianting.clientcustomerorderservice.SkuSellQuantityModification; | 44 | import com.infoloop.tianting.clientcustomerorderservice.SkuSellQuantityModification; |
| 44 | import com.infoloop.tianting.clientcustomerorderservice.UpdateClientCustomerOrderRpcRequest; | 45 | import com.infoloop.tianting.clientcustomerorderservice.UpdateClientCustomerOrderRpcRequest; |
| 45 | import com.infoloop.tianting.clientcustomerorderservice.UpdateClientCustomerOrderRpcResponse; | 46 | import com.infoloop.tianting.clientcustomerorderservice.UpdateClientCustomerOrderRpcResponse; |
| 47 | +import com.infoloop.tianting.clientresourcetagservice.SingleResourceLabelEntityRefsResponse; | ||
| 46 | import com.infoloop.tianting.context.LoginContextHolder; | 48 | import com.infoloop.tianting.context.LoginContextHolder; |
| 47 | import com.infoloop.tianting.exception.ClientEndExceptions; | 49 | import com.infoloop.tianting.exception.ClientEndExceptions; |
| 48 | import com.infoloop.tianting.exception.ErrorCodeEnum; | 50 | import com.infoloop.tianting.exception.ErrorCodeEnum; |
| ... | @@ -102,6 +104,7 @@ public class OrderServiceRpcClient { | ... | @@ -102,6 +104,7 @@ public class OrderServiceRpcClient { |
| 102 | private final MenuServiceRpcClient menuServiceRpcClient; | 104 | private final MenuServiceRpcClient menuServiceRpcClient; |
| 103 | private final SkuServiceRpcClient skuServiceRpcClient; | 105 | private final SkuServiceRpcClient skuServiceRpcClient; |
| 104 | private final OperatorServiceRpcClient operatorServiceRpcClient; | 106 | private final OperatorServiceRpcClient operatorServiceRpcClient; |
| 107 | + private final ClientResourceTagServiceRpcClient clientResourceTagServiceRpcClient; | ||
| 105 | private final RedissonClient redissonClient; | 108 | private final RedissonClient redissonClient; |
| 106 | private final DelayedQueue<AutoCancelParam> delayedQueue; | 109 | private final DelayedQueue<AutoCancelParam> delayedQueue; |
| 107 | 110 | ||
| ... | @@ -119,8 +122,7 @@ public class OrderServiceRpcClient { | ... | @@ -119,8 +122,7 @@ public class OrderServiceRpcClient { |
| 119 | GetClientCustomerOrdersByCustomerIdRpcRequest.newBuilder().setCustomerId(customerId).build()).getResponsesList(); | 122 | GetClientCustomerOrdersByCustomerIdRpcRequest.newBuilder().setCustomerId(customerId).build()).getResponsesList(); |
| 120 | } | 123 | } |
| 121 | 124 | ||
| 122 | - public List<SingleClientCustomerOrderRpcResponse> getOrdersByCondition( | 125 | + public List<SingleClientCustomerOrderRpcResponse> getOrdersByCondition(QueryOrderByConditionDto queryOrderDto) { |
| 123 | - QueryOrderByConditionDto queryOrderDto) { | ||
| 124 | final var request = QueryClientCustomerOrdersByConditionRpcRequest.newBuilder() | 126 | final var request = QueryClientCustomerOrdersByConditionRpcRequest.newBuilder() |
| 125 | .setEnterpriseId(queryOrderDto.getEnterpriseId()) | 127 | .setEnterpriseId(queryOrderDto.getEnterpriseId()) |
| 126 | .setShouldFilterOpenIds(queryOrderDto.getShouldFilterOpenId()) | 128 | .setShouldFilterOpenIds(queryOrderDto.getShouldFilterOpenId()) |
| ... | @@ -147,6 +149,8 @@ public class OrderServiceRpcClient { | ... | @@ -147,6 +149,8 @@ public class OrderServiceRpcClient { |
| 147 | .addAllOpenIds(List.of(queryOrderDto.getOpenId())) | 149 | .addAllOpenIds(List.of(queryOrderDto.getOpenId())) |
| 148 | .setShouldFilterPayStatus(queryOrderDto.getShouldFilterPayStatus()) | 150 | .setShouldFilterPayStatus(queryOrderDto.getShouldFilterPayStatus()) |
| 149 | .setPayStatus(queryOrderDto.getPayStatus()) | 151 | .setPayStatus(queryOrderDto.getPayStatus()) |
| 152 | + .setShouldFilterStatues(queryOrderDto.getShouldFilterStatues()) | ||
| 153 | + .addAllStatues(queryOrderDto.getStatues()) | ||
| 150 | .build(); | 154 | .build(); |
| 151 | return orderServiceRpcBlockingStub.queryClientCustomerOrdersByCondition(request).getResponsesList(); | 155 | return orderServiceRpcBlockingStub.queryClientCustomerOrdersByCondition(request).getResponsesList(); |
| 152 | } | 156 | } |
| ... | @@ -601,6 +605,7 @@ public class OrderServiceRpcClient { | ... | @@ -601,6 +605,7 @@ public class OrderServiceRpcClient { |
| 601 | if (orderResponse.getIsCreated()) { | 605 | if (orderResponse.getIsCreated()) { |
| 602 | // 用餐时间为当天,并且非在线支付餐单,发送消息给客户端 | 606 | // 用餐时间为当天,并且非在线支付餐单,发送消息给客户端 |
| 603 | if (createOrderDto.getMealTime().toLocalDate().equals(LocalDate.now()) && menuById.getResponse().getOrderRuleJson().getModeOfPayment() != ModeOfPaymentEnum.ONLINE) { | 607 | if (createOrderDto.getMealTime().toLocalDate().equals(LocalDate.now()) && menuById.getResponse().getOrderRuleJson().getModeOfPayment() != ModeOfPaymentEnum.ONLINE) { |
| 608 | + final var userIds = clientResourceTagServiceRpcClient.getOperatorIdsByStallIds(List.of(createOrderDto.getStallId())).stream().map(SingleResourceLabelEntityRefsResponse::getEntityId).distinct().map(String::valueOf).collect(Collectors.toList()); | ||
| 604 | final var orderCreateSuccessData = OrderCreateSuccessData.builder() | 609 | final var orderCreateSuccessData = OrderCreateSuccessData.builder() |
| 605 | .orderId(orderResponse.getId()) | 610 | .orderId(orderResponse.getId()) |
| 606 | .build(); | 611 | .build(); |
| ... | @@ -612,7 +617,7 @@ public class OrderServiceRpcClient { | ... | @@ -612,7 +617,7 @@ public class OrderServiceRpcClient { |
| 612 | .data(orderCreateSuccessData) | 617 | .data(orderCreateSuccessData) |
| 613 | .build(); | 618 | .build(); |
| 614 | try { | 619 | try { |
| 615 | - WebSocketServer.sendMessageByUserTypes(List.of(UserTypeEnum.CLIENT, UserTypeEnum.KDS), data); | 620 | + WebSocketServer.sendMessageByUserTypes(List.of(UserTypeEnum.CLIENT, UserTypeEnum.KDS), userIds, data); |
| 616 | } catch (IOException e) { | 621 | } catch (IOException e) { |
| 617 | log.error("Failed to send message to user", e); | 622 | log.error("Failed to send message to user", e); |
| 618 | } | 623 | } |
| ... | @@ -636,6 +641,15 @@ public class OrderServiceRpcClient { | ... | @@ -636,6 +641,15 @@ public class OrderServiceRpcClient { |
| 636 | return CreateOrderResponse.builder().id(orderResponse.getId()).isCreated(true).build(); | 641 | return CreateOrderResponse.builder().id(orderResponse.getId()).isCreated(true).build(); |
| 637 | } | 642 | } |
| 638 | 643 | ||
| 644 | + public boolean batchUpdateClientCustomerOrders(LoginContextHolder.LoginInfo loginInfo, List<ClientCustomerOrderModification> modifications) { | ||
| 645 | + return orderServiceRpcBlockingStub.batchUpdateClientCustomerOrders(BatchUpdateClientCustomerOrdersRpcRequest.newBuilder() | ||
| 646 | + .setEnterpriseId(loginInfo.getEnterpriseId()) | ||
| 647 | + .setUpdatedBy(loginInfo.getId()) | ||
| 648 | + .setUpdateSource(OrderSourceEnum.forNumber(loginInfo.getLoginSource().getValue())) | ||
| 649 | + .addAllModifications(modifications) | ||
| 650 | + .build()).getIsUpdated(); | ||
| 651 | + } | ||
| 652 | + | ||
| 639 | 653 | ||
| 640 | public List<SingleSkuSellQuantityRpcResponse> querySkuSellQuantitiesByStall(int enterpriseId, int stallId) { | 654 | public List<SingleSkuSellQuantityRpcResponse> querySkuSellQuantitiesByStall(int enterpriseId, int stallId) { |
| 641 | return orderServiceRpcBlockingStub.querySkuSellQuantitiesByStall(QuerySkuSellQuantitiesByStallRpcRequest.newBuilder() | 655 | return orderServiceRpcBlockingStub.querySkuSellQuantitiesByStall(QuerySkuSellQuantitiesByStallRpcRequest.newBuilder() | ... | ... |
| ... | @@ -3,6 +3,7 @@ package com.infoloop.tianting.service.impl; | ... | @@ -3,6 +3,7 @@ package com.infoloop.tianting.service.impl; |
| 3 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse; | 3 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse; |
| 4 | import com.infoloop.tianting.clientcustomerservice.SingleClientCustomerRpcResponse; | 4 | import com.infoloop.tianting.clientcustomerservice.SingleClientCustomerRpcResponse; |
| 5 | import com.infoloop.tianting.context.LoginContextHolder; | 5 | import com.infoloop.tianting.context.LoginContextHolder; |
| 6 | +import com.infoloop.tianting.logic.async.HisCustomerRoomNoTask; | ||
| 6 | import com.infoloop.tianting.menuservice.SingleClientCustomerMenuRefRpcResponse; | 7 | import com.infoloop.tianting.menuservice.SingleClientCustomerMenuRefRpcResponse; |
| 7 | import com.infoloop.tianting.model.dto.ClientCustomerDbDTO.ClientCustomerDto; | 8 | import com.infoloop.tianting.model.dto.ClientCustomerDbDTO.ClientCustomerDto; |
| 8 | import com.infoloop.tianting.model.dto.ClientCustomerDbDTO.CurrentClientCustomerDto; | 9 | import com.infoloop.tianting.model.dto.ClientCustomerDbDTO.CurrentClientCustomerDto; |
| ... | @@ -29,6 +30,7 @@ import lombok.extern.slf4j.Slf4j; | ... | @@ -29,6 +30,7 @@ import lombok.extern.slf4j.Slf4j; |
| 29 | import org.springframework.beans.factory.annotation.Autowired; | 30 | import org.springframework.beans.factory.annotation.Autowired; |
| 30 | import org.springframework.stereotype.Service; | 31 | import org.springframework.stereotype.Service; |
| 31 | 32 | ||
| 33 | +import java.io.IOException; | ||
| 32 | import java.time.LocalDate; | 34 | import java.time.LocalDate; |
| 33 | import java.time.LocalDateTime; | 35 | import java.time.LocalDateTime; |
| 34 | import java.util.ArrayList; | 36 | import java.util.ArrayList; |
| ... | @@ -45,6 +47,7 @@ public class ClientCustomerServiceImpl implements ClientCustomerService { | ... | @@ -45,6 +47,7 @@ public class ClientCustomerServiceImpl implements ClientCustomerService { |
| 45 | private final ClientCustomerServiceHttpClient clientCustomerServiceHttpClient; | 47 | private final ClientCustomerServiceHttpClient clientCustomerServiceHttpClient; |
| 46 | private final OrderServiceRpcClient orderServiceRpcClient; | 48 | private final OrderServiceRpcClient orderServiceRpcClient; |
| 47 | private final MenuServiceRpcClient menuServiceRpcClient; | 49 | private final MenuServiceRpcClient menuServiceRpcClient; |
| 50 | + private final HisCustomerRoomNoTask hisCustomerRoomNoTask; | ||
| 48 | 51 | ||
| 49 | @Override | 52 | @Override |
| 50 | public ClientCustomerDto getClientCustomerByHISCustomerId(String hisCustomerId) { | 53 | public ClientCustomerDto getClientCustomerByHISCustomerId(String hisCustomerId) { |
| ... | @@ -575,4 +578,9 @@ public class ClientCustomerServiceImpl implements ClientCustomerService { | ... | @@ -575,4 +578,9 @@ public class ClientCustomerServiceImpl implements ClientCustomerService { |
| 575 | .build(); | 578 | .build(); |
| 576 | } | 579 | } |
| 577 | 580 | ||
| 581 | + @Override | ||
| 582 | + public void synchronizationHisClientCustomer() throws IOException { | ||
| 583 | + hisCustomerRoomNoTask.synchronization(LoginContextHolder.getLoginInfo()); | ||
| 584 | + } | ||
| 585 | + | ||
| 578 | } | 586 | } | ... | ... |
| ... | @@ -138,6 +138,7 @@ message SingleClientCustomerOrderRpcResponse { | ... | @@ -138,6 +138,7 @@ message SingleClientCustomerOrderRpcResponse { |
| 138 | bool isRead = 33; | 138 | bool isRead = 33; |
| 139 | bool isConfirm = 34; | 139 | bool isConfirm = 34; |
| 140 | bool isAllocation = 35; | 140 | bool isAllocation = 35; |
| 141 | + string syncRoomNo = 36; | ||
| 141 | } | 142 | } |
| 142 | 143 | ||
| 143 | message GetClientCustomerOrderByIdRpcRequest { | 144 | message GetClientCustomerOrderByIdRpcRequest { |
| ... | @@ -243,6 +244,8 @@ message QueryClientCustomerOrdersByConditionRpcRequest { | ... | @@ -243,6 +244,8 @@ message QueryClientCustomerOrdersByConditionRpcRequest { |
| 243 | bool isConfirm = 45; | 244 | bool isConfirm = 45; |
| 244 | bool shouldFilterIsAllocation = 46; | 245 | bool shouldFilterIsAllocation = 46; |
| 245 | bool isAllocation = 47; | 246 | bool isAllocation = 47; |
| 247 | + bool shouldFilterStatues = 48; | ||
| 248 | + repeated OrderStatusEnum statues = 49; | ||
| 246 | } | 249 | } |
| 247 | 250 | ||
| 248 | message QueryClientCustomerOrdersByConditionRpcResponse { | 251 | message QueryClientCustomerOrdersByConditionRpcResponse { |
| ... | @@ -370,6 +373,8 @@ message ClientCustomerOrderModification { | ... | @@ -370,6 +373,8 @@ message ClientCustomerOrderModification { |
| 370 | bool isConfirm = 51; | 373 | bool isConfirm = 51; |
| 371 | bool shouldUpdateIsAllocation = 52; | 374 | bool shouldUpdateIsAllocation = 52; |
| 372 | bool isAllocation = 53; | 375 | bool isAllocation = 53; |
| 376 | + bool shouldUpdateSyncRoomNo = 54; | ||
| 377 | + string syncRoomNo = 55; | ||
| 373 | } | 378 | } |
| 374 | 379 | ||
| 375 | message UpdateClientCustomerOrderRpcRequest { | 380 | message UpdateClientCustomerOrderRpcRequest { | ... | ... |
| ... | @@ -40,6 +40,7 @@ service ClientCustomerServiceRpc { | ... | @@ -40,6 +40,7 @@ service ClientCustomerServiceRpc { |
| 40 | rpc GetClientCustomerHospitalRecordByCustomerId (GetClientCustomerHospitalRecordByCustomerIdRpcRequest) returns (GetClientCustomerHospitalRecordByCustomerIdRpcResponse) {} | 40 | rpc GetClientCustomerHospitalRecordByCustomerId (GetClientCustomerHospitalRecordByCustomerIdRpcRequest) returns (GetClientCustomerHospitalRecordByCustomerIdRpcResponse) {} |
| 41 | //根据客户IDS查询住院记录 | 41 | //根据客户IDS查询住院记录 |
| 42 | rpc GetClientCustomerHospitalRecordsByCustomerIds (GetClientCustomerHospitalRecordsByCustomerIdsRpcRequest) returns (GetClientCustomerHospitalRecordsByCustomerIdsRpcResponse) {} | 42 | rpc GetClientCustomerHospitalRecordsByCustomerIds (GetClientCustomerHospitalRecordsByCustomerIdsRpcRequest) returns (GetClientCustomerHospitalRecordsByCustomerIdsRpcResponse) {} |
| 43 | + rpc GetClientCustomerHospitalRecordsByHISCustomerIds (GetClientCustomerHospitalRecordsByHISCustomerIdsRpcRequest) returns (GetClientCustomerHospitalRecordsByHISCustomerIdsRpcResponse) {} | ||
| 43 | rpc QueryClientCustomerHospitalRecordsByCondition (QueryClientCustomerHospitalRecordsByConditionRpcRequest) returns (QueryClientCustomerHospitalRecordsByConditionRpcResponse) {} | 44 | rpc QueryClientCustomerHospitalRecordsByCondition (QueryClientCustomerHospitalRecordsByConditionRpcRequest) returns (QueryClientCustomerHospitalRecordsByConditionRpcResponse) {} |
| 44 | rpc CreateClientCustomerHospitalRecord (CreateClientCustomerHospitalRecordRpcRequest) returns (CreateClientCustomerHospitalRecordRpcResponse) {} | 45 | rpc CreateClientCustomerHospitalRecord (CreateClientCustomerHospitalRecordRpcRequest) returns (CreateClientCustomerHospitalRecordRpcResponse) {} |
| 45 | rpc BatchCreateClientCustomerHospitalRecords (BatchCreateClientCustomerHospitalRecordsRpcRequest) returns (BatchCreateClientCustomerHospitalRecordsRpcResponse) {} | 46 | rpc BatchCreateClientCustomerHospitalRecords (BatchCreateClientCustomerHospitalRecordsRpcRequest) returns (BatchCreateClientCustomerHospitalRecordsRpcResponse) {} |
| ... | @@ -385,6 +386,16 @@ message GetClientCustomerHospitalRecordsByCustomerIdsRpcResponse { | ... | @@ -385,6 +386,16 @@ message GetClientCustomerHospitalRecordsByCustomerIdsRpcResponse { |
| 385 | repeated SingleClientCustomerHospitalRecordRpcResponse responses = 1; | 386 | repeated SingleClientCustomerHospitalRecordRpcResponse responses = 1; |
| 386 | } | 387 | } |
| 387 | 388 | ||
| 389 | +message GetClientCustomerHospitalRecordsByHISCustomerIdsRpcRequest { | ||
| 390 | + repeated string HISCustomerIds = 1; | ||
| 391 | + int32 enterpriseId = 2; | ||
| 392 | + bool includeDeleted = 3; | ||
| 393 | +} | ||
| 394 | + | ||
| 395 | +message GetClientCustomerHospitalRecordsByHISCustomerIdsRpcResponse { | ||
| 396 | + repeated SingleClientCustomerHospitalRecordRpcResponse responses = 1; | ||
| 397 | +} | ||
| 398 | + | ||
| 388 | message QueryClientCustomerHospitalRecordsByConditionRpcRequest { | 399 | message QueryClientCustomerHospitalRecordsByConditionRpcRequest { |
| 389 | int32 enterpriseId = 1; | 400 | int32 enterpriseId = 1; |
| 390 | bool shouldFilterClientIds = 2; | 401 | bool shouldFilterClientIds = 2; | ... | ... |
| ... | @@ -58,7 +58,7 @@ grpc.meal-service.port=3017 | ... | @@ -58,7 +58,7 @@ grpc.meal-service.port=3017 |
| 58 | grpc.delivery-service.url=47.101.193.136 | 58 | grpc.delivery-service.url=47.101.193.136 |
| 59 | grpc.delivery-service.port=3017 | 59 | grpc.delivery-service.port=3017 |
| 60 | 60 | ||
| 61 | -grpc.operator-service.url=47.101.193.136 | 61 | +grpc.operator-service.url=115.190.92.112 |
| 62 | grpc.operator-service.port=3031 | 62 | grpc.operator-service.port=3031 |
| 63 | 63 | ||
| 64 | grpc.woperator-service.url=47.101.193.136 | 64 | grpc.woperator-service.url=47.101.193.136 |
| ... | @@ -67,6 +67,9 @@ grpc.woperator-service.port=3028 | ... | @@ -67,6 +67,9 @@ grpc.woperator-service.port=3028 |
| 67 | grpc.enterprise-resource-service.url=47.101.193.136 | 67 | grpc.enterprise-resource-service.url=47.101.193.136 |
| 68 | grpc.enterprise-resource-service.port=3026 | 68 | grpc.enterprise-resource-service.port=3026 |
| 69 | 69 | ||
| 70 | +grpc.client-resource-service.url=47.101.193.136 | ||
| 71 | +grpc.client-resource-service.port=3019 | ||
| 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