Toggle navigation
Toggle navigation
This project
Loading...
Sign in
jiujian
/
client-customer-order-api
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
zhuyifan
2025-03-06 11:06:21 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6cd094a61758b5b072b6fc6dc0c47145ec5a604c
6cd094a6
1 parent
5ce457eb
同步房间号
Hide whitespace changes
Inline
Side-by-side
Showing
38 changed files
with
691 additions
and
421 deletions
src/main/java/com/infoloop/tianting/config/GrpcConfig.java
src/main/java/com/infoloop/tianting/config/TaskPoolConfig.java
src/main/java/com/infoloop/tianting/constant/ConfigConstants.java
src/main/java/com/infoloop/tianting/context/LoginContextHolder.java
src/main/java/com/infoloop/tianting/controller/CategoryController.java
src/main/java/com/infoloop/tianting/controller/ClientCustomerController.java
src/main/java/com/infoloop/tianting/controller/ClientOrderController.java
src/main/java/com/infoloop/tianting/controller/InventoryController.java
src/main/java/com/infoloop/tianting/controller/LabelController.java
src/main/java/com/infoloop/tianting/controller/LoginController.java
src/main/java/com/infoloop/tianting/controller/MealController.java
src/main/java/com/infoloop/tianting/controller/MenuController.java
src/main/java/com/infoloop/tianting/intercepter/LoginInterceptor.java
src/main/java/com/infoloop/tianting/intercepter/WebSocketHandshakeInterceptor.java
src/main/java/com/infoloop/tianting/logic/async/HisCustomerRoomNoTask.java
src/main/java/com/infoloop/tianting/model/dto/OrderDbDTO.java
src/main/java/com/infoloop/tianting/server/WebSocketServer.java
src/main/java/com/infoloop/tianting/server/message/MessageTypeEnum.java
src/main/java/com/infoloop/tianting/server/message/NoticeTypeEnum.java
src/main/java/com/infoloop/tianting/server/message/data/CustomerAlterRoomNoData.java
src/main/java/com/infoloop/tianting/service/ClientCustomerService.java
src/main/java/com/infoloop/tianting/service/client/ClientCustomerServiceRpcClient.java
src/main/java/com/infoloop/tianting/service/client/ClientResourceTagServiceRpcClient.java
src/main/java/com/infoloop/tianting/service/client/MeiZhongYiHeServiceClient.java
src/main/java/com/infoloop/tianting/service/client/OperatorServiceRpcClient.java
src/main/java/com/infoloop/tianting/service/client/OrderServiceRpcClient.java
src/main/java/com/infoloop/tianting/service/client/PayServiceClient.java
src/main/java/com/infoloop/tianting/service/impl/CategoriesServiceImpl.java
src/main/java/com/infoloop/tianting/service/impl/ClientCustomerServiceImpl.java
src/main/java/com/infoloop/tianting/service/impl/DeliveryRuleServiceImpl.java
src/main/java/com/infoloop/tianting/service/impl/InventoryServiceImpl.java
src/main/java/com/infoloop/tianting/service/impl/KdsServiceImpl.java
src/main/java/com/infoloop/tianting/service/impl/LoginServiceImpl.java
src/main/java/com/infoloop/tianting/service/impl/MenuServiceImpl.java
src/main/java/com/infoloop/tianting/service/impl/OrderServiceImpl.java
src/main/proto/ClientCustomerOrderService.proto
src/main/proto/ClientCustomerService.proto
src/main/resources/application.properties
src/main/java/com/infoloop/tianting/config/GrpcConfig.java
View file @
6cd094a
...
...
@@ -8,6 +8,7 @@ import com.infoloop.tianting.WOperatorServiceProtoRpcGrpc;
import
com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderServiceRpcGrpc
;
import
com.infoloop.tianting.clientcustomerservice.ClientCustomerServiceRpcGrpc
;
import
com.infoloop.tianting.clientinventoryservice.TiantingClientInventoryServiceRpcGrpc
;
import
com.infoloop.tianting.clientresourcetagservice.ClientResourceTagServiceRpcGrpc
;
import
com.infoloop.tianting.deliveryruleservice.TiantingDeliveryRuleServiceRpcGrpc
;
import
com.infoloop.tianting.enterpriseresourcetagservice.EnterpriseResourceTagServiceRpcGrpc
;
import
com.infoloop.tianting.menuservice.MenuServiceRpcGrpc
;
...
...
@@ -32,6 +33,9 @@ import static com.infoloop.tianting.constant.ConfigConstants.CLIENT_CUSTOMER_SER
import
static
com
.
infoloop
.
tianting
.
constant
.
ConfigConstants
.
CLIENT_INVENTORY_SERVICE_CHANNEL
;
import
static
com
.
infoloop
.
tianting
.
constant
.
ConfigConstants
.
CLIENT_INVENTORY_SERVICE_RPC_PORT
;
import
static
com
.
infoloop
.
tianting
.
constant
.
ConfigConstants
.
CLIENT_INVENTORY_SERVICE_RPC_URL
;
import
static
com
.
infoloop
.
tianting
.
constant
.
ConfigConstants
.
CLIENT_RESOURCE_SERVICE_CHANNEL
;
import
static
com
.
infoloop
.
tianting
.
constant
.
ConfigConstants
.
CLIENT_RESOURCE_SERVICE_RPC_PORT
;
import
static
com
.
infoloop
.
tianting
.
constant
.
ConfigConstants
.
CLIENT_RESOURCE_SERVICE_RPC_URL
;
import
static
com
.
infoloop
.
tianting
.
constant
.
ConfigConstants
.
DELIVERY_SERVICE_CHANNEL
;
import
static
com
.
infoloop
.
tianting
.
constant
.
ConfigConstants
.
DELIVERY_SERVICE_RPC_PORT
;
import
static
com
.
infoloop
.
tianting
.
constant
.
ConfigConstants
.
DELIVERY_SERVICE_RPC_URL
;
...
...
@@ -268,4 +272,21 @@ public class GrpcConfig {
public
MeiZhongYiHeServiceRpcGrpc
.
MeiZhongYiHeServiceRpcBlockingStub
meiZhongYiHeServiceRpcBlockingStub
(
@Autowired
@Qualifier
(
MEIZHONGYIHE_SERVICE_CHANNEL
)
final
ManagedChannel
channel
)
{
return
MeiZhongYiHeServiceRpcGrpc
.
newBlockingStub
(
channel
);
}
@Bean
(
CLIENT_RESOURCE_SERVICE_CHANNEL
)
public
ManagedChannel
clientResourceServiceChannel
(
@Value
(
CLIENT_RESOURCE_SERVICE_RPC_URL
)
final
String
url
,
@Value
(
CLIENT_RESOURCE_SERVICE_RPC_PORT
)
final
int
port
,
@Autowired
final
ClientInterceptor
clientInterceptor
)
{
return
NettyChannelBuilder
.
forAddress
(
url
,
port
)
.
idleTimeout
(
DEFAULT_TIMEOUT_DAYS
,
TimeUnit
.
DAYS
)
.
intercept
(
clientInterceptor
)
.
usePlaintext
()
.
maxInboundMessageSize
(
Integer
.
MAX_VALUE
)
.
build
();
}
@Bean
public
ClientResourceTagServiceRpcGrpc
.
ClientResourceTagServiceRpcBlockingStub
clientResourceTagServiceRpcBlockingStub
(
@Autowired
@Qualifier
(
CLIENT_RESOURCE_SERVICE_CHANNEL
)
final
ManagedChannel
channel
)
{
return
ClientResourceTagServiceRpcGrpc
.
newBlockingStub
(
channel
);
}
}
...
...
src/main/java/com/infoloop/tianting/config/TaskPoolConfig.java
View file @
6cd094a
...
...
@@ -4,6 +4,7 @@ import com.infoloop.tianting.context.LoginContextHolder;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.core.task.TaskDecorator
;
import
org.springframework.scheduling.TaskScheduler
;
import
org.springframework.scheduling.annotation.EnableAsync
;
...
...
@@ -23,6 +24,7 @@ import static com.infoloop.tianting.constant.ConfigConstants.SCHEDULED_TASK_EXEC
@EnableAsync
public
class
TaskPoolConfig
{
@Primary
@Bean
(
SCHEDULED_TASK_EXECUTOR
)
public
TaskScheduler
scheduledExecutorService
()
{
final
var
scheduler
=
new
ThreadPoolTaskScheduler
();
...
...
src/main/java/com/infoloop/tianting/constant/ConfigConstants.java
View file @
6cd094a
...
...
@@ -76,6 +76,10 @@ public interface ConfigConstants {
String
MEIZHONGYIHE_SERVICE_RPC_PORT
=
"${grpc.meizhongyihe-service.port}"
;
String
MEIZHONGYIHE_SERVICE_CHANNEL
=
"meizhongyihe-service-channel"
;
String
CLIENT_RESOURCE_SERVICE_RPC_URL
=
"${grpc.client-resource-service.url}"
;
String
CLIENT_RESOURCE_SERVICE_RPC_PORT
=
"${grpc.client-resource-service.port}"
;
String
CLIENT_RESOURCE_SERVICE_CHANNEL
=
"client-resource-tag-service-channel"
;
String
ASYNC_EXECUTOR
=
"asyncExecutor"
;
String
SCHEDULED_TASK_EXECUTOR
=
"scheduledTaskExecutor"
;
...
...
src/main/java/com/infoloop/tianting/context/LoginContextHolder.java
View file @
6cd094a
package
com
.
infoloop
.
tianting
.
context
;
import
com.infoloop.tianting.enums.LoginSourceEnum
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
...
...
@@ -61,6 +62,8 @@ public class LoginContextHolder {
@Builder
.
Default
private
String
openId
=
""
;
private
LoginSourceEnum
loginSource
;
}
}
...
...
src/main/java/com/infoloop/tianting/controller/CategoryController.java
View file @
6cd094a
...
...
@@ -5,17 +5,17 @@ import com.infoloop.tianting.model.dto.CategoryDbDTO.CategoryDto;
import
com.infoloop.tianting.service.CategoriesService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
java.util.List
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
@Api
(
tags
=
"Category"
)
@ApiSupport
(
order
=
-
1
)
@Slf4j
...
...
@@ -26,7 +26,7 @@ public class CategoryController {
private
final
CategoriesService
categoriesService
;
@ApiOperation
(
value
=
"
根据enterpriseId获取CategoriesAll
"
)
@ApiOperation
(
value
=
"
获取企业所有品类信息
"
)
@GetMapping
(
"/enterprise/categories"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
CategoryDto
>
queryCategoriesAll
()
{
...
...
src/main/java/com/infoloop/tianting/controller/ClientCustomerController.java
View file @
6cd094a
...
...
@@ -14,13 +14,15 @@ import org.springframework.http.HttpStatus;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.io.IOException
;
import
java.util.List
;
@Api
(
tags
=
"
ClientCustomer
"
)
@Api
(
tags
=
"
客户
"
)
@ApiSupport
(
order
=
-
1
)
@Slf4j
@Validated
...
...
@@ -28,57 +30,63 @@ import java.util.List;
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
ClientCustomerController
{
private
final
ClientCustomerService
clientCustomerService
;
private
final
ClientCustomerService
clientCustomerService
;
@ApiOperation
(
value
=
"根据hisCustomerId获取ClientCustomer"
)
@GetMapping
(
"/customers/his/{hisCustomerId}"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
ClientCustomerDto
getClientCustomerByHISCustomerId
(
@PathVariable
String
hisCustomerId
)
{
return
clientCustomerService
.
getClientCustomerByHISCustomerId
(
hisCustomerId
);
}
@ApiOperation
(
value
=
"根据hisCustomerId获取ClientCustomer"
)
@GetMapping
(
"/customers/his/{hisCustomerId}"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
ClientCustomerDto
getClientCustomerByHISCustomerId
(
@PathVariable
String
hisCustomerId
)
{
return
clientCustomerService
.
getClientCustomerByHISCustomerId
(
hisCustomerId
);
}
@ApiOperation
(
value
=
"根据hisCustomerNo获取ClientCustomer"
)
@GetMapping
(
"/his/customer/{hisCustomerNo}"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
ClientCustomerDto
getClientCustomerByHISCustomerNo
(
@PathVariable
String
hisCustomerNo
)
{
return
clientCustomerService
.
getClientCustomerByHISCustomerNo
(
hisCustomerNo
);
}
@ApiOperation
(
value
=
"根据hisCustomerNo获取ClientCustomer"
)
@GetMapping
(
"/his/customer/{hisCustomerNo}"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
ClientCustomerDto
getClientCustomerByHISCustomerNo
(
@PathVariable
String
hisCustomerNo
)
{
return
clientCustomerService
.
getClientCustomerByHISCustomerNo
(
hisCustomerNo
);
}
@ApiOperation
(
value
=
"根据customerId获取ClientCustomer"
)
@GetMapping
(
"/customers/{customerId}"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
ClientCustomerDto
getClientCustomerByCustomerId
(
@PathVariable
Integer
customerId
)
{
return
clientCustomerService
.
getClientCustomerByCustomerId
(
customerId
);
}
@ApiOperation
(
value
=
"根据customerId获取ClientCustomer"
)
@GetMapping
(
"/customers/{customerId}"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
ClientCustomerDto
getClientCustomerByCustomerId
(
@PathVariable
Integer
customerId
)
{
return
clientCustomerService
.
getClientCustomerByCustomerId
(
customerId
);
}
@ApiOperation
(
value
=
"根据phone获取ClientCustomer"
)
@GetMapping
(
"/customers/phone/{phone}"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
ClientCustomerDto
getClientCustomerByPhone
(
@PathVariable
String
phone
)
{
return
clientCustomerService
.
getClientCustomerByPhone
(
phone
);
}
@ApiOperation
(
value
=
"根据phone获取ClientCustomer"
)
@GetMapping
(
"/customers/phone/{phone}"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
ClientCustomerDto
getClientCustomerByPhone
(
@PathVariable
String
phone
)
{
return
clientCustomerService
.
getClientCustomerByPhone
(
phone
);
}
@ApiOperation
(
value
=
"根据customerId获取住院记录"
)
@GetMapping
(
"/enterprise/{enterpriseId}/hospitalRecords/customers/{customerId}"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
HospitalRecordDto
>
getHospitalRecords
(
@PathVariable
Integer
enterpriseId
,
@PathVariable
Integer
customerId
)
{
return
clientCustomerService
.
getClientCustomerHospitalRecordsByCustomerId
(
enterpriseId
,
customerId
);
}
@ApiOperation
(
value
=
"根据customerId获取住院记录"
)
@GetMapping
(
"/enterprise/{enterpriseId}/hospitalRecords/customers/{customerId}"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
HospitalRecordDto
>
getHospitalRecords
(
@PathVariable
Integer
enterpriseId
,
@PathVariable
Integer
customerId
)
{
return
clientCustomerService
.
getClientCustomerHospitalRecordsByCustomerId
(
enterpriseId
,
customerId
);
}
@ApiOperation
(
value
=
"获取今日在住"
)
@GetMapping
(
"/clientCustomers/today/statistic"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
TodayOrderDto
getClientCustomerTodayOrderStatistic
(
@RequestParam
String
customerToken
)
{
return
clientCustomerService
.
getTodayOrderStatistic
(
customerToken
);
}
@ApiOperation
(
value
=
"获取今日在住"
)
@GetMapping
(
"/clientCustomers/today/statistic"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
TodayOrderDto
getClientCustomerTodayOrderStatistic
(
@RequestParam
String
customerToken
)
{
return
clientCustomerService
.
getTodayOrderStatistic
(
customerToken
);
}
@ApiOperation
(
value
=
"获取his今日在住"
)
@GetMapping
(
"/hisClientCustomers/today/statistic"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
TodayOrderDto
getHisClientCustomerTodayOrderStatistic
(
@RequestParam
String
customerToken
)
{
return
clientCustomerService
.
getTodayOrderStatisticForHis
(
customerToken
);
}
@ApiOperation
(
value
=
"获取his今日在住"
)
@GetMapping
(
"/hisClientCustomers/today/statistic"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
TodayOrderDto
getHisClientCustomerTodayOrderStatistic
(
@RequestParam
String
customerToken
)
{
return
clientCustomerService
.
getTodayOrderStatisticForHis
(
customerToken
);
}
@ApiOperation
(
value
=
"同步his客户信息"
)
@PostMapping
(
"/hisclientcustomers/synchronization"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
void
synchronizationHisClientCustomer
()
throws
IOException
{
clientCustomerService
.
synchronizationHisClientCustomer
();
}
}
...
...
src/main/java/com/infoloop/tianting/controller/ClientOrderController.java
View file @
6cd094a
...
...
@@ -26,13 +26,13 @@ import javax.validation.Valid;
@RestController
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
ClientOrderController
{
private
final
OrderService
orderService
;
private
final
OrderService
orderService
;
@ApiOperation
(
value
=
"院区端分页获取用户
订单"
)
@PostMapping
(
"/client/orders/pagination"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
OrderPageResult
<
OrderDto
>
getOrderByByPagination
(
@Valid
@RequestBody
OrderDbDTO
.
QueryOrderByPaginationDto
queryOrderDto
)
{
return
orderService
.
getOrdersByPagination
(
queryOrderDto
);
}
@ApiOperation
(
value
=
"院区端
订单"
)
@PostMapping
(
"/client/orders/pagination"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
OrderPageResult
<
OrderDto
>
getOrderByByPagination
(
@Valid
@RequestBody
OrderDbDTO
.
QueryOrderByPaginationDto
queryOrderDto
)
{
return
orderService
.
getOrdersByPagination
(
queryOrderDto
);
}
}
...
...
src/main/java/com/infoloop/tianting/controller/InventoryController.java
View file @
6cd094a
...
...
@@ -43,16 +43,14 @@ public class InventoryController {
@ApiOperation
(
value
=
"根据ClientId获取Stalls"
)
@GetMapping
(
"/enterprises/{enterpriseId}/clients/{clientId}/stalls"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
ClientDto
>
getStallsByClientId
(
@PathVariable
Integer
enterpriseId
,
@PathVariable
Integer
clientId
)
{
public
List
<
ClientDto
>
getStallsByClientId
(
@PathVariable
Integer
enterpriseId
,
@PathVariable
Integer
clientId
)
{
return
inventoryService
.
getStallsByClientId
(
enterpriseId
,
clientId
);
}
@ApiOperation
(
value
=
"获取桌号"
)
@PostMapping
(
"/tableCodes"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
ClientTableCodeDto
>
getTableCodes
(
@Valid
@RequestBody
TableCodeQueryConditionDto
tableCodeQueryConditionDto
)
{
public
List
<
ClientTableCodeDto
>
getTableCodes
(
@Valid
@RequestBody
TableCodeQueryConditionDto
tableCodeQueryConditionDto
)
{
return
inventoryService
.
queryClientTableCodesByCondition
(
tableCodeQueryConditionDto
);
}
}
...
...
src/main/java/com/infoloop/tianting/controller/LabelController.java
View file @
6cd094a
package
com
.
infoloop
.
tianting
.
controller
;
import
com.github.xiaoymin.knife4j.annotations.ApiSupport
;
import
com.infoloop.tianting.clientcustomerservice.BatchCreateClientCustomerLabelRefsRpcRequest
;
import
com.infoloop.tianting.model.dto.ClientLabelDTO
;
import
com.infoloop.tianting.model.dto.ClientLabelDTO.BatchCreateCustomerLabelRefResponseDto
;
import
com.infoloop.tianting.model.dto.ClientLabelDTO.BatchDeleteCustomerLabelRefRequestDto
;
import
com.infoloop.tianting.model.dto.ClientLabelDTO.BatchDeleteCustomerLabelRefResponseDto
;
import
com.infoloop.tianting.model.dto.ClientLabelDTO.CustomerLabelRefDetailDto
;
import
com.infoloop.tianting.model.dto.ClientLabelDTO.HisAllergy
;
import
com.infoloop.tianting.model.dto.ClientLabelDTO.HisMedicalAdviceDto
;
import
com.infoloop.tianting.model.dto.ClientLabelDTO.LabelDto
;
import
com.infoloop.tianting.model.dto.MealDbDTO
;
import
com.infoloop.tianting.model.dto.MealDbDTO.MealDto
;
import
com.infoloop.tianting.service.ClientCustomerService
;
import
com.infoloop.tianting.service.DeliveryRuleService
;
import
com.infoloop.tianting.service.MeiZhongYiHeService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
java.util.List
;
import
javax.validation.Valid
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -32,6 +26,9 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.Valid
;
import
java.util.List
;
@Api
(
tags
=
"标签"
)
@ApiSupport
(
order
=
-
1
)
@Slf4j
...
...
@@ -39,53 +36,50 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
LabelController
{
private
final
DeliveryRuleService
deliveryRuleService
;
private
final
ClientCustomerService
clientCustomerService
;
private
final
MeiZhongYiHeService
meiZhongYiHeService
;
@ApiOperation
(
value
=
"按类型获取标签"
)
@PostMapping
(
"/labels"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
LabelDto
>
getMiniProgramLabels
(
@Valid
@RequestBody
ClientLabelDTO
.
QueryLabelsDto
queryLabelsDto
)
{
return
deliveryRuleService
.
getLabelsByTypes
(
queryLabelsDto
);
}
private
final
DeliveryRuleService
deliveryRuleService
;
private
final
ClientCustomerService
clientCustomerService
;
private
final
MeiZhongYiHeService
meiZhongYiHeService
;
@ApiOperation
(
value
=
"按类型获取标签"
)
@PostMapping
(
"/labels"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
LabelDto
>
getMiniProgramLabels
(
@Valid
@RequestBody
ClientLabelDTO
.
QueryLabelsDto
queryLabelsDto
)
{
return
deliveryRuleService
.
getLabelsByTypes
(
queryLabelsDto
);
}
@ApiOperation
(
value
=
"批量创建用户绑定标签"
)
@PostMapping
(
"/labels/batch"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
BatchCreateCustomerLabelRefResponseDto
batchCreateCustomerLabelRef
(
@Valid
@RequestBody
ClientLabelDTO
.
BatchCreateCustomerLabelRefDto
batchCreateCustomerLabelRefDto
)
{
return
clientCustomerService
.
batchCreateClientCustomerLabelRefs
(
batchCreateCustomerLabelRefDto
);
}
@ApiOperation
(
value
=
"批量创建用户绑定标签"
)
@PostMapping
(
"/labels/batch"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
BatchCreateCustomerLabelRefResponseDto
batchCreateCustomerLabelRef
(
@Valid
@RequestBody
ClientLabelDTO
.
BatchCreateCustomerLabelRefDto
batchCreateCustomerLabelRefDto
)
{
return
clientCustomerService
.
batchCreateClientCustomerLabelRefs
(
batchCreateCustomerLabelRefDto
);
}
@ApiOperation
(
value
=
"获取用户已绑定的标签"
)
@PostMapping
(
"/enterprises/{enterpriseId}/labels/customers/{customerId}"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
CustomerLabelRefDetailDto
>
getCustomerLabelsByCustomerId
(
@PathVariable
Integer
enterpriseId
,
@PathVariable
Integer
customerId
)
{
return
clientCustomerService
.
getCustomerLabelsByCustomerId
(
enterpriseId
,
customerId
);
}
@ApiOperation
(
value
=
"获取用户已绑定的标签"
)
@PostMapping
(
"/enterprises/{enterpriseId}/labels/customers/{customerId}"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
CustomerLabelRefDetailDto
>
getCustomerLabelsByCustomerId
(
@PathVariable
Integer
enterpriseId
,
@PathVariable
Integer
customerId
)
{
return
clientCustomerService
.
getCustomerLabelsByCustomerId
(
enterpriseId
,
customerId
);
}
@ApiOperation
(
value
=
"批量删除用户绑定的标签"
)
@DeleteMapping
(
"/customer/label/refs"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
BatchDeleteCustomerLabelRefResponseDto
getCustomerLabelsByCustomerId
(
@Valid@RequestBody
ClientLabelDTO
.
BatchDeleteCustomerLabelRefRequestDto
request
)
{
return
clientCustomerService
.
deleteClientCustomerLabelRefsByIds
(
request
);
}
@ApiOperation
(
value
=
"批量删除用户绑定的标签"
)
@DeleteMapping
(
"/customer/label/refs"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
BatchDeleteCustomerLabelRefResponseDto
getCustomerLabelsByCustomerId
(
@Valid
@RequestBody
ClientLabelDTO
.
BatchDeleteCustomerLabelRefRequestDto
request
)
{
return
clientCustomerService
.
deleteClientCustomerLabelRefsByIds
(
request
);
}
@ApiOperation
(
value
=
"根据hisCustomerId查询用户绑定过敏源标签"
)
@GetMapping
(
"/allergy/hisCustomer/{hisCustomerId}"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
HisAllergy
>
getHisCustomerAllergiesByCustomerId
(
@PathVariable
String
hisCustomerId
)
{
return
meiZhongYiHeService
.
getHisCustomerAllergiesByCustomerId
(
hisCustomerId
);
}
@ApiOperation
(
value
=
"根据hisCustomerId查询用户绑定过敏源标签"
)
@GetMapping
(
"/allergy/hisCustomer/{hisCustomerId}"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
HisAllergy
>
getHisCustomerAllergiesByCustomerId
(
@PathVariable
String
hisCustomerId
)
{
return
meiZhongYiHeService
.
getHisCustomerAllergiesByCustomerId
(
hisCustomerId
);
}
@ApiOperation
(
value
=
"根据contractNo查询His用户医嘱"
)
@GetMapping
(
"/medicalAdvice/hisCustomer/{contractNo}"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
HisMedicalAdviceDto
>
getHisCustomerMedicalAdviceByContractNo
(
@PathVariable
String
contractNo
)
{
return
meiZhongYiHeService
.
getHisCustomerMedicalAdvicesByContractNo
(
contractNo
);
}
@ApiOperation
(
value
=
"根据contractNo查询His用户医嘱"
)
@GetMapping
(
"/medicalAdvice/hisCustomer/{contractNo}"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
HisMedicalAdviceDto
>
getHisCustomerMedicalAdviceByContractNo
(
@PathVariable
String
contractNo
)
{
return
meiZhongYiHeService
.
getHisCustomerMedicalAdvicesByContractNo
(
contractNo
);
}
}
...
...
src/main/java/com/infoloop/tianting/controller/LoginController.java
View file @
6cd094a
...
...
@@ -27,13 +27,13 @@ import java.security.NoSuchAlgorithmException;
@RestController
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
LoginController
{
private
final
LoginService
loginService
;
private
final
LoginService
loginService
;
@SaIgnore
@ApiOperation
(
value
=
"登陆"
)
@PostMapping
(
"/login"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
SaTokenInfo
login
(
@Valid
@RequestBody
PermissionDTO
.
LoginDto
loginDto
)
throws
NoSuchAlgorithmException
{
return
loginService
.
login
(
loginDto
);
}
@SaIgnore
@ApiOperation
(
value
=
"登陆"
)
@PostMapping
(
"/login"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
SaTokenInfo
login
(
@Valid
@RequestBody
PermissionDTO
.
LoginDto
loginDto
)
throws
NoSuchAlgorithmException
{
return
loginService
.
login
(
loginDto
);
}
}
...
...
src/main/java/com/infoloop/tianting/controller/MealController.java
View file @
6cd094a
...
...
@@ -6,20 +6,20 @@ import com.infoloop.tianting.model.dto.MealDbDTO.MealIdsDto;
import
com.infoloop.tianting.service.MealService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
java.util.List
;
import
javax.validation.Valid
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.Valid
;
import
java.util.List
;
@Api
(
tags
=
"餐别"
)
@ApiSupport
(
order
=
-
1
)
@Slf4j
...
...
@@ -27,20 +27,20 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
MealController
{
private
final
MealService
mealService
;
private
final
MealService
mealService
;
@ApiOperation
(
value
=
"根据ids获取餐别"
)
@PostMapping
(
"/meals"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
MealDto
>
getMealsByIds
(
@Valid
@RequestBody
MealIdsDto
mealIdsDto
)
{
return
mealService
.
getMealsByIds
(
mealIdsDto
.
getEnterpriseId
(),
mealIdsDto
.
getIds
());
}
@ApiOperation
(
value
=
"根据ids获取餐别"
)
@PostMapping
(
"/meals"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
MealDto
>
getMealsByIds
(
@Valid
@RequestBody
MealIdsDto
mealIdsDto
)
{
return
mealService
.
getMealsByIds
(
mealIdsDto
.
getEnterpriseId
(),
mealIdsDto
.
getIds
());
}
@ApiOperation
(
value
=
"获取enterprise所有餐别"
)
@GetMapping
(
"/enterprises/meals"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
MealDto
>
getAllMeals
()
{
return
mealService
.
getAllMeals
();
}
@ApiOperation
(
value
=
"获取enterprise所有餐别"
)
@GetMapping
(
"/enterprises/meals"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
MealDto
>
getAllMeals
()
{
return
mealService
.
getAllMeals
();
}
}
...
...
src/main/java/com/infoloop/tianting/controller/MenuController.java
View file @
6cd094a
...
...
@@ -36,52 +36,42 @@ public class MenuController {
@ApiOperation
(
value
=
"根据stallId获取小程序已发布餐单"
)
@GetMapping
(
"/enterprises/{enterpriseId}/stalls/{stallId}/menus"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
MenuDto
>
queryMiniProgramPublishedMenusByStallIds
(
@PathVariable
Integer
enterpriseId
,
@PathVariable
Integer
stallId
)
{
public
List
<
MenuDto
>
queryMiniProgramPublishedMenusByStallIds
(
@PathVariable
Integer
enterpriseId
,
@PathVariable
Integer
stallId
)
{
return
menuService
.
queryMiniProgramPublishedMenusByStallId
(
enterpriseId
,
stallId
);
}
@ApiOperation
(
value
=
"根据stallId获取所有已发布餐单"
)
@GetMapping
(
"/enterprises/{enterpriseId}/stalls/{stallId}/all/menus"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
MenuDto
>
queryPublishedMenusByStallIds
(
@PathVariable
Integer
enterpriseId
,
@PathVariable
Integer
stallId
)
{
public
List
<
MenuDto
>
queryPublishedMenusByStallIds
(
@PathVariable
Integer
enterpriseId
,
@PathVariable
Integer
stallId
)
{
return
menuService
.
queryPublishedMenusByStallId
(
enterpriseId
,
stallId
);
}
@ApiOperation
(
value
=
"根据MenuId获取餐单"
)
@GetMapping
(
"/enterprises/{enterpriseId}/menus/{menuId}"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
MenuDto
getMenuById
(
@PathVariable
Integer
enterpriseId
,
@PathVariable
Integer
menuId
)
{
public
MenuDto
getMenuById
(
@PathVariable
Integer
enterpriseId
,
@PathVariable
Integer
menuId
)
{
return
menuService
.
getMenuById
(
enterpriseId
,
menuId
);
}
@ApiOperation
(
value
=
"根据MenuId获取餐单详情"
)
@GetMapping
(
"/enterprises/{enterpriseId}/menusDetails/{menuId}"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
MenuDetailDto
>
queryMenuDetailsByMenuIds
(
@PathVariable
Integer
enterpriseId
,
@PathVariable
Integer
menuId
)
{
public
List
<
MenuDetailDto
>
queryMenuDetailsByMenuIds
(
@PathVariable
Integer
enterpriseId
,
@PathVariable
Integer
menuId
)
{
return
menuService
.
queryMenuDetailsByMenuId
(
enterpriseId
,
menuId
);
}
@ApiOperation
(
value
=
"获取餐单绑定"
)
@GetMapping
(
"/enterprises/{enterpriseId}/menuRefs/{customerId}"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
MenuRefDto
>
queryMenuRefsByCustomerId
(
@PathVariable
Integer
enterpriseId
,
@PathVariable
Integer
customerId
)
{
public
List
<
MenuRefDto
>
queryMenuRefsByCustomerId
(
@PathVariable
Integer
enterpriseId
,
@PathVariable
Integer
customerId
)
{
return
menuService
.
getClientCustomerMenuRefsByCustomerId
(
enterpriseId
,
customerId
);
}
@ApiOperation
(
value
=
"批量创建餐单绑定"
)
@PostMapping
(
"/menuRefs/creation"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
BatchCreateMenuRefsResponseDto
batchCreateMenuRefsByCustomerId
(
@Valid
@RequestBody
BatchCreateMenuRefsDto
batchCreateMenuRefsDto
)
{
public
BatchCreateMenuRefsResponseDto
batchCreateMenuRefsByCustomerId
(
@Valid
@RequestBody
BatchCreateMenuRefsDto
batchCreateMenuRefsDto
)
{
return
menuService
.
batchCreateMenuRefs
(
batchCreateMenuRefsDto
);
}
...
...
src/main/java/com/infoloop/tianting/intercepter/LoginInterceptor.java
View file @
6cd094a
...
...
@@ -67,7 +67,6 @@ public class LoginInterceptor extends HandlerInterceptorAdapter {
StpUtil
.
checkLogin
();
final
var
enterpriseId
=
Convert
.
toInt
(
StpUtil
.
getExtra
(
CommonConstants
.
ENTERPRISE_ID
));
final
var
loginSource
=
Convert
.
toInt
(
StpUtil
.
getExtra
(
CommonConstants
.
LOGIN_SOURCE
));
log
.
info
(
"Login success, enterpriseId: {}, loginSource: {}"
,
enterpriseId
,
loginSource
);
if
(
loginSource
.
equals
(
LoginSourceEnum
.
CUSTOMER
.
getValue
()))
{
final
var
openId
=
Convert
.
toStr
(
StpUtil
.
getExtra
(
CommonConstants
.
OPEN_ID
));
final
var
loginId
=
StpUtil
.
getLoginIdAsInt
();
...
...
@@ -77,8 +76,7 @@ public class LoginInterceptor extends HandlerInterceptorAdapter {
ResponseUtil
.
write
(
response
,
ResponseResult
.
failed
(
ErrorCodeEnum
.
VALIDATE_FAILED
));
return
false
;
}
log
.
info
(
"Customer login success, customerId: {}, enterpriseId: {}, openId:{}"
,
loginId
,
enterpriseId
,
openId
);
builder
.
id
(
loginId
).
enterpriseId
(
enterpriseId
).
name
(
customer
.
getResponse
().
getName
()).
openId
(
openId
);
builder
.
id
(
loginId
).
enterpriseId
(
enterpriseId
).
name
(
customer
.
getResponse
().
getName
()).
openId
(
openId
).
loginSource
(
LoginSourceEnum
.
CUSTOMER
);
return
true
;
}
else
if
(
loginSource
.
equals
(
LoginSourceEnum
.
OPERATOR
.
getValue
())){
final
var
loginId
=
StpUtil
.
getLoginIdAsInt
();
...
...
@@ -88,20 +86,19 @@ public class LoginInterceptor extends HandlerInterceptorAdapter {
ResponseUtil
.
write
(
response
,
ResponseResult
.
failed
(
ErrorCodeEnum
.
VALIDATE_FAILED
));
return
false
;
}
builder
.
id
(
loginId
).
enterpriseId
(
enterpriseId
).
name
(
opeartor
.
getName
());
builder
.
id
(
loginId
).
enterpriseId
(
enterpriseId
).
name
(
opeartor
.
getName
())
.
loginSource
(
LoginSourceEnum
.
OPERATOR
)
;
return
true
;
}
else
if
(
loginSource
.
equals
(
LoginSourceEnum
.
KDS
.
getValue
()))
{
final
var
loginId
=
StpUtil
.
getLoginIdAsInt
();
final
var
operator
=
wOperatorServiceRpcClient
.
getWOperatorById
(
loginId
).
getResponse
();
if
(
operator
.
getId
()
==
0
)
{
throw
ClientEndExceptions
.
AuthenticationFailure
.
build
(
ErrorCodeEnum
.
UNAUTHORIZED
.
name
());
}
builder
.
id
(
loginId
).
enterpriseId
(
enterpriseId
).
name
(
operator
.
getName
());
builder
.
id
(
loginId
).
enterpriseId
(
enterpriseId
).
name
(
operator
.
getName
())
.
loginSource
(
LoginSourceEnum
.
KDS
)
;
return
true
;
}
else
{
final
var
loginId
=
StpUtil
.
getLoginIdAsString
();
builder
.
openId
(
loginId
).
enterpriseId
(
enterpriseId
);
builder
.
openId
(
loginId
).
enterpriseId
(
enterpriseId
)
.
loginSource
(
LoginSourceEnum
.
MINI_PROGRAM
)
;
return
true
;
}
}
...
...
src/main/java/com/infoloop/tianting/intercepter/WebSocketHandshakeInterceptor.java
View file @
6cd094a
package
com
.
infoloop
.
tianting
.
intercepter
;
import
cn.dev33.satoken.stp.StpUtil
;
import
cn.hutool.core.convert.Convert
;
import
com.infoloop.tianting.constant.CommonConstants
;
import
com.infoloop.tianting.enums.LoginSourceEnum
;
import
org.springframework.http.server.ServerHttpRequest
;
import
org.springframework.http.server.ServerHttpResponse
;
import
org.springframework.
util.StringUtils
;
import
org.springframework.
http.server.ServletServerHttpRequest
;
import
org.springframework.web.socket.WebSocketHandler
;
import
org.springframework.web.socket.server.HandshakeInterceptor
;
...
...
@@ -17,15 +14,15 @@ public class WebSocketHandshakeInterceptor implements HandshakeInterceptor {
@Override
public
boolean
beforeHandshake
(
ServerHttpRequest
request
,
ServerHttpResponse
response
,
WebSocketHandler
wsHandler
,
Map
<
String
,
Object
>
attributes
)
{
final
var
authorization
=
request
.
getHeaders
().
getFirst
(
CommonConstants
.
AUTHORIZATION
);
if
(
StringUtils
.
isEmpty
(
authorization
))
{
return
false
;
if
(
request
instanceof
ServletServerHttpRequest
)
{
ServletServerHttpRequest
servletRequest
=
(
ServletServerHttpRequest
)
request
;
String
userType
=
servletRequest
.
getServletRequest
().
getParameter
(
CommonConstants
.
USER_TYPE
);
String
userId
=
servletRequest
.
getServletRequest
().
getParameter
(
CommonConstants
.
USER_ID
);
attributes
.
put
(
CommonConstants
.
USER_TYPE
,
userType
);
attributes
.
put
(
CommonConstants
.
USER_ID
,
userId
);
return
true
;
}
final
var
loginSource
=
Convert
.
toInt
(
StpUtil
.
getExtra
(
CommonConstants
.
LOGIN_SOURCE
));
final
var
loginSourceEnum
=
LoginSourceEnum
.
getByValue
(
loginSource
);
attributes
.
put
(
CommonConstants
.
USER_TYPE
,
loginSourceEnum
.
getUserType
().
name
());
attributes
.
put
(
CommonConstants
.
USER_ID
,
StpUtil
.
getLoginIdAsString
());
return
true
;
return
false
;
}
@Override
...
...
src/main/java/com/infoloop/tianting/logic/async/HisCustomerRoomNoTask.java
0 → 100644
View file @
6cd094a
package
com
.
infoloop
.
tianting
.
logic
.
async
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonObject
;
import
com.infoloop.rpc.meizhongyiheservice.Customer
;
import
com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderModification
;
import
com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum
;
import
com.infoloop.tianting.clientcustomerservice.ClientCustomerHospitalRecordModification
;
import
com.infoloop.tianting.clientcustomerservice.ClientCustomerOperationRecordCreation
;
import
com.infoloop.tianting.clientcustomerservice.ClientCustomerOperationRecordTypeEnum
;
import
com.infoloop.tianting.clientcustomerservice.SingleClientCustomerHospitalRecordRpcResponse
;
import
com.infoloop.tianting.clientcustomerservice.SingleClientCustomerRpcResponse
;
import
com.infoloop.tianting.clientinventoryservice.SingleClientRpcResponse
;
import
com.infoloop.tianting.context.LoginContextHolder
;
import
com.infoloop.tianting.model.dto.OrderDbDTO
;
import
com.infoloop.tianting.server.WebSocketServer
;
import
com.infoloop.tianting.server.message.MessageTypeEnum
;
import
com.infoloop.tianting.server.message.NoticeTypeEnum
;
import
com.infoloop.tianting.server.message.SocketMessage
;
import
com.infoloop.tianting.server.message.data.CustomerAlterRoomNoData
;
import
com.infoloop.tianting.server.session.UserSessionKey
;
import
com.infoloop.tianting.server.session.UserTypeEnum
;
import
com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient
;
import
com.infoloop.tianting.service.client.ClientResourceTagServiceRpcClient
;
import
com.infoloop.tianting.service.client.InventoryServiceRpcClient
;
import
com.infoloop.tianting.service.client.MeiZhongYiHeServiceClient
;
import
com.infoloop.tianting.service.client.OperatorServiceRpcClient
;
import
com.infoloop.tianting.service.client.OrderServiceRpcClient
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Component
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
static
com
.
infoloop
.
tianting
.
constant
.
ConfigConstants
.
ASYNC_EXECUTOR
;
@Slf4j
@Component
@RequiredArgsConstructor
public
class
HisCustomerRoomNoTask
{
private
final
OperatorServiceRpcClient
operatorServiceRpcClient
;
private
final
ClientResourceTagServiceRpcClient
clientResourceTagServiceRpcClient
;
private
final
InventoryServiceRpcClient
inventoryServiceRpcClient
;
private
final
MeiZhongYiHeServiceClient
meiZhongYiHeServiceClient
;
private
final
OrderServiceRpcClient
orderServiceRpcClient
;
private
final
ClientCustomerServiceRpcClient
clientCustomerServiceRpcClient
;
@Async
(
ASYNC_EXECUTOR
)
public
void
synchronization
(
LoginContextHolder
.
LoginInfo
loginInfo
)
throws
IOException
{
final
var
cOperatorById
=
operatorServiceRpcClient
.
getCOperatorById
(
loginInfo
.
getId
());
final
var
stallIdsList
=
clientResourceTagServiceRpcClient
.
getUserResources
(
cOperatorById
.
getEnterpriseId
(),
cOperatorById
.
getClientId
(),
cOperatorById
.
getId
()).
getStallIdsList
();
final
var
stalls
=
inventoryServiceRpcClient
.
getStallsByIds
(
cOperatorById
.
getEnterpriseId
(),
stallIdsList
).
getClientsList
();
final
var
queryOrderDto
=
OrderDbDTO
.
QueryOrderByConditionDto
.
builder
()
.
enterpriseId
(
loginInfo
.
getEnterpriseId
())
.
shouldFilterStallIds
(
true
)
.
stallIds
(
stallIdsList
)
.
shouldFilterStatues
(
true
)
.
statues
(
List
.
of
(
OrderStatusEnum
.
TO_PREPARE
,
OrderStatusEnum
.
PREPARING
))
.
build
();
final
var
orders
=
orderServiceRpcClient
.
getOrdersByCondition
(
queryOrderDto
);
if
(
orders
.
isEmpty
())
{
return
;
}
final
var
stallCodes
=
stalls
.
stream
().
filter
(
e
->
!
e
.
getIsDelivery
()).
map
(
SingleClientRpcResponse:
:
getCode
).
collect
(
Collectors
.
toList
());
final
var
customersList
=
meiZhongYiHeServiceClient
.
getCustomersByCondition
(
stallCodes
);
final
var
hisCustomerIds
=
customersList
.
stream
().
map
(
Customer:
:
getCustomerId
).
collect
(
Collectors
.
toList
());
final
var
customerMap
=
customersList
.
stream
().
collect
(
Collectors
.
toMap
(
Customer:
:
getCustomerId
,
Function
.
identity
()));
final
var
clientCustomerMap
=
clientCustomerServiceRpcClient
.
getClientCustomersByHISCustomerIds
(
hisCustomerIds
)
.
getResponsesList
()
.
stream
()
.
collect
(
Collectors
.
toMap
(
SingleClientCustomerRpcResponse:
:
getId
,
Function
.
identity
(),
(
a
,
b
)
->
a
));
final
var
alterRoomNoCustomers
=
orders
.
stream
()
.
map
(
order
->
{
final
var
singleClientCustomerRpcResponse
=
clientCustomerMap
.
get
(
order
.
getCustomerId
());
if
(
singleClientCustomerRpcResponse
==
null
)
{
return
null
;
}
final
var
customer
=
customerMap
.
get
(
singleClientCustomerRpcResponse
.
getHISCustomerId
());
if
(
customer
==
null
)
{
log
.
error
(
"customer is null for HIS customerId: {}"
,
singleClientCustomerRpcResponse
.
getHISCustomerId
());
return
null
;
}
final
var
syncRoomNo
=
customer
.
getCustomerHospitalRecord
().
getRoomNo
();
if
(!
syncRoomNo
.
equals
(
order
.
getRoomNo
()))
{
log
.
info
(
"customer roomNo alter for orderId: {}, roomNo: {}, syncRoomNo: {}"
,
order
.
getId
(),
order
.
getRoomNo
(),
syncRoomNo
);
return
CustomerAlterRoomNoData
.
AlterRoomNoCustomer
.
builder
()
.
orderId
(
order
.
getId
())
.
customerId
(
singleClientCustomerRpcResponse
.
getId
())
.
roomNo
(
order
.
getRoomNo
())
.
alterRoomNo
(
syncRoomNo
)
.
build
();
}
return
null
;
})
.
filter
(
Objects:
:
nonNull
)
.
collect
(
Collectors
.
toList
());
if
(
alterRoomNoCustomers
.
isEmpty
())
{
return
;
}
final
var
isUpdated
=
orderServiceRpcClient
.
batchUpdateClientCustomerOrders
(
loginInfo
,
alterRoomNoCustomers
.
stream
()
.
map
(
e
->
ClientCustomerOrderModification
.
newBuilder
()
.
setId
(
e
.
getOrderId
())
.
setShouldUpdateSyncRoomNo
(
true
)
.
setSyncRoomNo
(
e
.
getAlterRoomNo
())
.
build
())
.
collect
(
Collectors
.
toList
()));
if
(!
isUpdated
)
{
log
.
error
(
"OrderServiceRpcClient.batchUpdateClientCustomerOrders error"
);
return
;
}
final
var
customerIds
=
alterRoomNoCustomers
.
stream
()
.
map
(
CustomerAlterRoomNoData
.
AlterRoomNoCustomer
::
getCustomerId
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
final
var
clientCustomerHospitalRecordMap
=
clientCustomerServiceRpcClient
.
getClientCustomerHospitalRecordsByCustomerIds
(
loginInfo
.
getEnterpriseId
(),
customerIds
).
stream
().
collect
(
Collectors
.
toMap
(
SingleClientCustomerHospitalRecordRpcResponse:
:
getCustomerId
,
Function
.
identity
()));
clientCustomerServiceRpcClient
.
batchUpdateClientCustomerHospitalRecords
(
loginInfo
,
alterRoomNoCustomers
.
stream
()
.
map
(
e
->
{
final
var
hospitalRecordRpcResponse
=
clientCustomerHospitalRecordMap
.
get
(
e
.
getCustomerId
());
return
ClientCustomerHospitalRecordModification
.
newBuilder
()
.
setId
(
hospitalRecordRpcResponse
.
getId
())
.
setShouldUpdateRoomNo
(
true
)
.
setRoomNo
(
e
.
getAlterRoomNo
())
.
build
();
})
.
collect
(
Collectors
.
toList
()));
final
var
gson
=
new
Gson
();
final
var
uniqueAlterRoomNoCustomers
=
alterRoomNoCustomers
.
stream
().
collect
(
Collectors
.
toMap
(
CustomerAlterRoomNoData
.
AlterRoomNoCustomer
::
getCustomerId
,
Function
.
identity
(),
(
existing
,
replacement
)
->
existing
)).
values
();
final
var
creations
=
uniqueAlterRoomNoCustomers
.
stream
()
.
map
(
customer
->
{
var
originalJson
=
new
JsonObject
();
originalJson
.
addProperty
(
"roomNo"
,
customer
.
getRoomNo
());
var
adjustJson
=
new
JsonObject
();
adjustJson
.
addProperty
(
"roomNo"
,
customer
.
getAlterRoomNo
());
return
ClientCustomerOperationRecordCreation
.
newBuilder
()
.
setClientCustomerId
(
customer
.
getCustomerId
())
.
setOperator
(
loginInfo
.
getName
())
.
setType
(
ClientCustomerOperationRecordTypeEnum
.
CLIENT_CUSTOMER_OPERATION_RECORD_TYPE_UPDATE
)
.
setShouldCreateOriginalJson
(
true
)
.
setOriginalJson
(
gson
.
toJson
(
originalJson
))
.
setShouldCreateAdjustJson
(
true
)
.
setAdjustJson
(
gson
.
toJson
(
adjustJson
))
.
build
();
})
.
collect
(
Collectors
.
toList
());
clientCustomerServiceRpcClient
.
batchCreateClientCustomerOperationRecords
(
loginInfo
,
creations
);
final
var
data
=
SocketMessage
.<
CustomerAlterRoomNoData
>
builder
()
.
type
(
MessageTypeEnum
.
CUSTOMER
)
.
noticeType
(
NoticeTypeEnum
.
CUSTOMER_ALTER_ROOM_NO
)
.
subject
(
NoticeTypeEnum
.
CUSTOMER_ALTER_ROOM_NO
.
getDescription
())
.
message
(
"有"
+
customerIds
.
size
()
+
" 个客户房间号发生了变更,系统已显示最新房间号。"
)
.
data
(
CustomerAlterRoomNoData
.
builder
().
alterRoomNoCustomers
(
alterRoomNoCustomers
).
build
())
.
build
();
WebSocketServer
.
sendMessageToUser
(
UserSessionKey
.
builder
().
userId
(
String
.
valueOf
(
loginInfo
.
getId
())).
userType
(
UserTypeEnum
.
CLIENT
).
build
(),
data
);
}
}
src/main/java/com/infoloop/tianting/model/dto/OrderDbDTO.java
View file @
6cd094a
...
...
@@ -17,6 +17,8 @@ import lombok.NoArgsConstructor;
import
lombok.ToString
;
import
javax.validation.Valid
;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotNull
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -117,6 +119,14 @@ public class OrderDbDTO {
private
Boolean
shouldFilterMenuId
=
false
;
@Builder
.
Default
private
Integer
menuId
=
0
;
@Builder
.
Default
private
Boolean
shouldFilterPayStatus
=
false
;
@Builder
.
Default
private
PayStatusEnum
payStatus
=
PayStatusEnum
.
UNKNOWN_PAY_STATUS
;
@Builder
.
Default
private
Boolean
shouldFilterStatues
=
false
;
@Builder
.
Default
private
List
<
OrderStatusEnum
>
statues
=
new
ArrayList
<>();
}
@Data
...
...
@@ -206,15 +216,19 @@ public class OrderDbDTO {
@RequestKeyParam
@ApiModelProperty
(
value
=
"档口 ID"
)
@NotNull
(
message
=
"档口 ID不能为空"
)
private
Integer
stallId
;
@ApiModelProperty
(
value
=
"客户 ID"
)
@NotNull
(
message
=
"客户 ID不能为空"
)
private
Integer
customerId
;
@ApiModelProperty
(
value
=
"餐单 id"
)
@NotNull
(
message
=
"餐单 id不能为空"
)
private
Integer
menuId
;
@ApiModelProperty
(
value
=
"用餐日期"
)
@NotNull
(
message
=
"用餐日期不能为空"
)
private
LocalDateTime
mealTime
;
@ApiModelProperty
(
value
=
"桌号"
)
...
...
@@ -224,9 +238,11 @@ public class OrderDbDTO {
private
String
remark
;
@ApiModelProperty
(
value
=
"支付方式"
)
@NotNull
(
message
=
"支付方式不能为空"
)
private
OnlinePayEnum
onlinePay
;
@ApiModelProperty
(
value
=
"订单菜品详情列表"
)
@NotEmpty
(
message
=
"订单菜品详情列表不能为空"
)
private
List
<
OperatorCreateOrderDetailDto
>
orderDetailDtos
;
}
...
...
@@ -240,10 +256,12 @@ public class OrderDbDTO {
private
Integer
enterpriseId
;
@ApiModelProperty
(
value
=
"院区 ID"
)
@NotNull
(
message
=
"院区 ID不能为空"
)
private
Integer
clientId
;
@RequestKeyParam
@ApiModelProperty
(
value
=
"档口 ID"
)
@NotNull
(
message
=
"档口 ID不能为空"
)
private
Integer
stallId
;
@ApiModelProperty
(
value
=
"需要创建客户 ID"
)
...
...
@@ -256,6 +274,7 @@ public class OrderDbDTO {
private
Integer
status
;
@ApiModelProperty
(
value
=
"餐单 id"
)
@NotNull
(
message
=
"餐单 id不能为空"
)
private
Integer
menuId
;
@ApiModelProperty
(
value
=
"订单商品总数"
)
...
...
@@ -265,6 +284,7 @@ public class OrderDbDTO {
private
Integer
payPrice
;
@ApiModelProperty
(
value
=
"支付方式"
)
@NotNull
(
message
=
"支付方式不能为空"
)
private
OnlinePayEnum
onlinePay
;
@ApiModelProperty
(
value
=
"支付时间"
)
...
...
@@ -280,6 +300,7 @@ public class OrderDbDTO {
private
String
transactionId
;
@ApiModelProperty
(
value
=
"用餐日期"
)
@NotNull
(
message
=
"用餐日期不能为空"
)
private
LocalDateTime
mealTime
;
@ApiModelProperty
(
value
=
"订餐地址"
)
...
...
@@ -309,7 +330,6 @@ public class OrderDbDTO {
@ApiModelProperty
(
value
=
"修改人 ID,修改人可能是院区端登陆的用户,也可能是 KDS 端登陆用户"
)
private
Integer
updatedBy
;
@ApiModelProperty
(
value
=
"更新来源:小程序点餐=1;院区端=2;kds=3;业务中台 = 4"
)
private
Integer
updateSource
;
...
...
@@ -317,6 +337,7 @@ public class OrderDbDTO {
private
CloseTimeType
closeTimeType
;
@ApiModelProperty
(
value
=
"订单菜品详情列表"
)
@NotEmpty
(
message
=
"订单菜品详情列表不能为空"
)
private
List
<
CreateOrderDetailDto
>
orderDetailDtos
;
}
...
...
@@ -392,6 +413,9 @@ public class OrderDbDTO {
@ApiModelProperty
(
value
=
"房间号"
)
private
String
roomNo
;
@ApiModelProperty
(
value
=
"是否变更房间号"
)
private
boolean
adjustRoomNo
;
@ApiModelProperty
(
value
=
"点餐桌码"
)
private
String
tableCode
;
...
...
src/main/java/com/infoloop/tianting/server/WebSocketServer.java
View file @
6cd094a
...
...
@@ -24,7 +24,7 @@ import java.util.stream.Collectors;
public
class
WebSocketServer
extends
TextWebSocketHandler
{
private
static
final
ConcurrentHashMap
<
UserSessionKey
,
UserSessionData
>
userSessions
=
new
ConcurrentHashMap
<>();
private
static
final
long
INACTIVITY_TIMEOUT
=
2
*
60
*
60
*
1000
;
private
static
final
long
INACTIVITY_TIMEOUT
=
60
*
60
*
1000
;
private
static
final
ScheduledExecutorService
scheduler
=
Executors
.
newScheduledThreadPool
(
1
);
static
{
...
...
@@ -34,6 +34,7 @@ public class WebSocketServer extends TextWebSocketHandler {
private
static
void
cleanInactiveSessions
()
{
final
var
currentTime
=
System
.
currentTimeMillis
();
final
var
iterator
=
userSessions
.
entrySet
().
iterator
();
log
.
info
(
"cleanInactiveSessions; sessions:{}"
,
userSessions
.
keySet
());
while
(
iterator
.
hasNext
())
{
final
var
entry
=
iterator
.
next
();
final
var
key
=
entry
.
getKey
();
...
...
@@ -79,6 +80,14 @@ public class WebSocketServer extends TextWebSocketHandler {
sendMessageToUsers
(
keys
,
socketMessage
);
}
public
static
<
T
>
void
sendMessageByUserTypes
(
List
<
UserTypeEnum
>
userTypes
,
List
<
String
>
authUserIds
,
SocketMessage
<
T
>
socketMessage
)
throws
IOException
{
final
var
keys
=
userSessions
.
keySet
().
stream
()
.
filter
(
userSessionData
->
userTypes
.
contains
(
userSessionData
.
getUserType
()))
.
filter
(
userSessionData
->
authUserIds
.
contains
(
userSessionData
.
getUserId
()))
.
collect
(
Collectors
.
toList
());
sendMessageToUsers
(
keys
,
socketMessage
);
}
public
static
void
closeConnection
(
UserSessionKey
key
)
{
final
var
userData
=
userSessions
.
get
(
key
);
if
(
userData
!=
null
)
{
...
...
@@ -108,8 +117,17 @@ public class WebSocketServer extends TextWebSocketHandler {
public
void
afterConnectionEstablished
(
WebSocketSession
session
)
{
final
var
key
=
getUserSessionKey
(
session
);
if
(
key
!=
null
)
{
final
var
existingSession
=
userSessions
.
remove
(
key
);
if
(
existingSession
!=
null
)
{
try
{
existingSession
.
closeSession
();
log
.
info
(
"WebSocket old connect closed,userId : {}, userType : {}"
,
key
.
getUserId
(),
key
.
getUserType
());
}
catch
(
IOException
e
)
{
log
.
error
(
"old WebSocket close failed,userId : {}, userType : {}"
,
key
.
getUserId
(),
key
.
getUserType
(),
e
);
}
}
userSessions
.
put
(
key
,
new
UserSessionData
(
session
));
log
.
info
(
"WebSocket connect success
:
userId : {}, userType : {}"
,
key
.
getUserId
(),
key
.
getUserType
());
log
.
info
(
"WebSocket connect success
,
userId : {}, userType : {}"
,
key
.
getUserId
(),
key
.
getUserType
());
}
else
{
log
.
warn
(
"WebSocket connect failed,unable to get valid user information"
);
}
...
...
src/main/java/com/infoloop/tianting/server/message/MessageTypeEnum.java
View file @
6cd094a
...
...
@@ -5,7 +5,8 @@ import lombok.Getter;
@Getter
public
enum
MessageTypeEnum
{
ORDER
(
"订单类型消息"
);
ORDER
(
"订单类型消息"
),
CUSTOMER
(
"客户类型消息"
);;
private
final
String
description
;
...
...
src/main/java/com/infoloop/tianting/server/message/NoticeTypeEnum.java
View file @
6cd094a
...
...
@@ -5,8 +5,10 @@ import lombok.Getter;
@Getter
public
enum
NoticeTypeEnum
{
ORDER_CREATED
(
"下单成功"
,
MessageTypeEnum
.
ORDER
),
ORDER_PAYMENT_SUCCESS
(
"支付成功"
,
MessageTypeEnum
.
ORDER
);
ORDER_PAYMENT_SUCCESS
(
"支付成功"
,
MessageTypeEnum
.
ORDER
),
CUSTOMER_ALTER_ROOM_NO
(
"客户变更房间号"
,
MessageTypeEnum
.
CUSTOMER
),
;
private
final
String
description
;
private
final
MessageTypeEnum
messageType
;
...
...
src/main/java/com/infoloop/tianting/server/message/data/CustomerAlterRoomNoData.java
0 → 100644
View file @
6cd094a
package
com
.
infoloop
.
tianting
.
server
.
message
.
data
;
import
lombok.Builder
;
import
lombok.Data
;
import
java.util.List
;
@Data
@Builder
public
class
CustomerAlterRoomNoData
{
private
List
<
AlterRoomNoCustomer
>
alterRoomNoCustomers
;
@Data
@Builder
public
static
class
AlterRoomNoCustomer
{
private
int
orderId
;
private
int
customerId
;
private
String
roomNo
;
private
String
alterRoomNo
;
}
}
src/main/java/com/infoloop/tianting/service/ClientCustomerService.java
View file @
6cd094a
...
...
@@ -9,6 +9,7 @@ import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchDeleteCustomerLabelRe
import
com.infoloop.tianting.model.dto.ClientLabelDTO.BatchDeleteCustomerLabelRefResponseDto
;
import
com.infoloop.tianting.model.dto.ClientLabelDTO.CustomerLabelRefDetailDto
;
import
java.io.IOException
;
import
java.util.List
;
public
interface
ClientCustomerService
{
...
...
@@ -36,4 +37,6 @@ public interface ClientCustomerService {
TodayOrderDto
getTodayOrderStatisticForHis
(
String
token
);
ClientCustomerDto
getClientCustomerByHISCustomerNo
(
String
hisCustomerNo
);
void
synchronizationHisClientCustomer
()
throws
IOException
;
}
...
...
src/main/java/com/infoloop/tianting/service/client/ClientCustomerServiceRpcClient.java
View file @
6cd094a
...
...
@@ -2,7 +2,11 @@ package com.infoloop.tianting.service.client;
import
com.infoloop.tianting.clientcustomerservice.BatchCreateClientCustomerLabelRefsRpcRequest
;
import
com.infoloop.tianting.clientcustomerservice.BatchCreateClientCustomerLabelRefsRpcResponse
;
import
com.infoloop.tianting.clientcustomerservice.BatchCreateClientCustomerOperationRecordsRpcRequest
;
import
com.infoloop.tianting.clientcustomerservice.BatchUpdateClientCustomerHospitalRecordsRpcRequest
;
import
com.infoloop.tianting.clientcustomerservice.ClientCustomerHospitalRecordModification
;
import
com.infoloop.tianting.clientcustomerservice.ClientCustomerLabelRefCreation
;
import
com.infoloop.tianting.clientcustomerservice.ClientCustomerOperationRecordCreation
;
import
com.infoloop.tianting.clientcustomerservice.ClientCustomerServiceRpcGrpc
;
import
com.infoloop.tianting.clientcustomerservice.DeleteClientCustomerLabelRefsByIdsRpcRequest
;
import
com.infoloop.tianting.clientcustomerservice.DeleteClientCustomerLabelRefsRpcResponse
;
...
...
@@ -18,12 +22,15 @@ import com.infoloop.tianting.clientcustomerservice.GetClientCustomerByMobileRpcR
import
com.infoloop.tianting.clientcustomerservice.GetClientCustomerByMobileRpcResponse
;
import
com.infoloop.tianting.clientcustomerservice.GetClientCustomerHospitalRecordByCustomerIdRpcRequest
;
import
com.infoloop.tianting.clientcustomerservice.GetClientCustomerHospitalRecordByCustomerIdRpcResponse
;
import
com.infoloop.tianting.clientcustomerservice.GetClientCustomerHospitalRecordsByCustomerIdsRpcRequest
;
import
com.infoloop.tianting.clientcustomerservice.GetClientCustomersByHISCustomerIdsRpcRequest
;
import
com.infoloop.tianting.clientcustomerservice.GetClientCustomersByHISCustomerIdsRpcResponse
;
import
com.infoloop.tianting.clientcustomerservice.GetClientCustomersByIdsRpcRequest
;
import
com.infoloop.tianting.clientcustomerservice.GetClientCustomersByIdsRpcResponse
;
import
com.infoloop.tianting.clientcustomerservice.QueryClientCustomerLabelRefsByConditionRpcRequest
;
import
com.infoloop.tianting.clientcustomerservice.QueryClientCustomerLabelRefsByConditionRpcResponse
;
import
com.infoloop.tianting.clientcustomerservice.SingleClientCustomerHospitalRecordRpcResponse
;
import
com.infoloop.tianting.context.LoginContextHolder
;
import
com.infoloop.tianting.model.dto.ClientLabelDTO.BatchCreateCustomerLabelRefDto
;
import
com.infoloop.tianting.model.dto.ClientLabelDTO.BatchDeleteCustomerLabelRefRequestDto
;
import
lombok.RequiredArgsConstructor
;
...
...
@@ -145,4 +152,32 @@ public class ClientCustomerServiceRpcClient {
.
build
();
return
clientCustomerServiceRpcBlockingStub
.
deleteClientCustomerLabelRefsByIds
(
request
);
}
public
List
<
SingleClientCustomerHospitalRecordRpcResponse
>
getClientCustomerHospitalRecordsByCustomerIds
(
int
enterpriseId
,
List
<
Integer
>
ids
)
{
final
var
request
=
GetClientCustomerHospitalRecordsByCustomerIdsRpcRequest
.
newBuilder
()
.
setEnterpriseId
(
enterpriseId
)
.
addAllCustomerIds
(
ids
)
.
build
();
return
clientCustomerServiceRpcBlockingStub
.
getClientCustomerHospitalRecordsByCustomerIds
(
request
).
getResponsesList
();
}
public
boolean
batchUpdateClientCustomerHospitalRecords
(
LoginContextHolder
.
LoginInfo
loginInfo
,
List
<
ClientCustomerHospitalRecordModification
>
modifications
)
{
final
var
request
=
BatchUpdateClientCustomerHospitalRecordsRpcRequest
.
newBuilder
()
.
setEnterpriseId
(
loginInfo
.
getEnterpriseId
())
.
setUpdatedBy
(
loginInfo
.
getId
())
.
setUpdateSource
(
loginInfo
.
getLoginSource
().
getValue
())
.
addAllModifications
(
modifications
)
.
build
();
return
clientCustomerServiceRpcBlockingStub
.
batchUpdateClientCustomerHospitalRecords
(
request
).
getIsUpdated
();
}
public
boolean
batchCreateClientCustomerOperationRecords
(
LoginContextHolder
.
LoginInfo
loginInfo
,
List
<
ClientCustomerOperationRecordCreation
>
creations
)
{
final
var
request
=
BatchCreateClientCustomerOperationRecordsRpcRequest
.
newBuilder
()
.
setEnterpriseId
(
loginInfo
.
getEnterpriseId
())
.
setCreatedBy
(
loginInfo
.
getId
())
.
setCreationSource
(
loginInfo
.
getLoginSource
().
getValue
())
.
addAllCreations
(
creations
)
.
build
();
return
clientCustomerServiceRpcBlockingStub
.
batchCreateClientCustomerOperationRecords
(
request
).
getIsCreated
();
}
}
...
...
src/main/java/com/infoloop/tianting/service/client/ClientResourceTagServiceRpcClient.java
0 → 100644
View file @
6cd094a
package
com
.
infoloop
.
tianting
.
service
.
client
;
import
com.infoloop.tianting.clientresourcetagservice.ClientResourceTagServiceRpcGrpc
;
import
com.infoloop.tianting.clientresourcetagservice.ResourceOperatorIdsGetByStallIdsRequest
;
import
com.infoloop.tianting.clientresourcetagservice.SingleResourceLabelEntityRefsResponse
;
import
com.infoloop.tianting.clientresourcetagservice.UserTagsAndResourcesGetRequest
;
import
com.infoloop.tianting.clientresourcetagservice.UserTagsAndResourcesGetResponse
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
@Service
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
ClientResourceTagServiceRpcClient
{
private
final
ClientResourceTagServiceRpcGrpc
.
ClientResourceTagServiceRpcBlockingStub
clientResourceTagServiceRpcBlockingStub
;
public
List
<
SingleResourceLabelEntityRefsResponse
>
getOperatorIdsByStallIds
(
List
<
Integer
>
stallIds
)
{
return
clientResourceTagServiceRpcBlockingStub
.
getOperatorIdsByStallIds
(
ResourceOperatorIdsGetByStallIdsRequest
.
newBuilder
()
.
addAllStallIds
(
stallIds
)
.
build
()).
getLabelEntityRefsList
();
}
public
UserTagsAndResourcesGetResponse
getUserResources
(
int
enterpriseId
,
int
clientId
,
int
operatorId
)
{
return
clientResourceTagServiceRpcBlockingStub
.
getUserResources
(
UserTagsAndResourcesGetRequest
.
newBuilder
()
.
setEnterpriseId
(
enterpriseId
)
.
setUserId
(
operatorId
)
.
setClientId
(
clientId
)
.
build
());
}
}
src/main/java/com/infoloop/tianting/service/client/MeiZhongYiHeServiceClient.java
View file @
6cd094a
package
com
.
infoloop
.
tianting
.
service
.
client
;
import
com.infoloop.rpc.meizhongyiheservice.Customer
;
import
com.infoloop.rpc.meizhongyiheservice.GetCustomerAllergiesByCustomerIdsRpcRequest
;
import
com.infoloop.rpc.meizhongyiheservice.GetCustomerAllergiesByCustomerIdsRpcResponse
;
import
com.infoloop.rpc.meizhongyiheservice.GetCustomerDetailByIdRpcRequest
;
import
com.infoloop.rpc.meizhongyiheservice.GetCustomerMedicalAdvicesByHospitalRecordIdsRpcRequest
;
import
com.infoloop.rpc.meizhongyiheservice.GetCustomerMedicalAdvicesByHospitalRecordIdsRpcResponse
;
import
com.infoloop.rpc.meizhongyiheservice.GetCustomersByConditionRpcRequest
;
import
com.infoloop.rpc.meizhongyiheservice.MeiZhongYiHeServiceRpcGrpc
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -31,4 +34,22 @@ public class MeiZhongYiHeServiceClient {
.
build
();
return
meiZhongYiHeServiceRpcBlockingStub
.
getCustomerMedicalAdvicesByHospitalRecordIds
(
request
);
}
public
Customer
getCustomerDetailById
(
String
HISCustomerId
,
String
contractNo
)
{
final
var
customer
=
meiZhongYiHeServiceRpcBlockingStub
.
getCustomerDetailById
(
GetCustomerDetailByIdRpcRequest
.
newBuilder
()
.
setCustomerId
(
HISCustomerId
)
.
setHospitalRecordId
(
contractNo
)
.
build
());
if
(!
customer
.
hasCustomer
())
{
return
null
;
}
return
customer
.
getCustomer
();
}
public
List
<
Customer
>
getCustomersByCondition
(
List
<
String
>
stallCodes
)
{
final
var
request
=
GetCustomersByConditionRpcRequest
.
newBuilder
()
.
addAllDeptCode
(
stallCodes
)
.
build
();
return
meiZhongYiHeServiceRpcBlockingStub
.
getCustomersByCondition
(
request
).
getCustomersList
();
}
}
...
...
src/main/java/com/infoloop/tianting/service/client/OperatorServiceRpcClient.java
View file @
6cd094a
...
...
@@ -21,7 +21,7 @@ public class OperatorServiceRpcClient {
return
cOperatorServiceProtoRpcBlockingStub
.
getCOperatorByMobileOrEmail
(
request
).
getResponse
();
}
public
SingleCOperatorRpcResponse
getCOperatorById
(
Integer
id
)
{
public
SingleCOperatorRpcResponse
getCOperatorById
(
int
id
)
{
final
var
request
=
GetCOperatorByIdRpcRequest
.
newBuilder
().
setId
(
id
).
build
();
return
cOperatorServiceProtoRpcBlockingStub
.
getCOperatorById
(
request
).
getResponse
();
}
...
...
src/main/java/com/infoloop/tianting/service/client/OrderServiceRpcClient.java
View file @
6cd094a
...
...
@@ -9,6 +9,7 @@ import com.infoloop.tianting.clientcustomerorderservice.BatchCreateOrderOperatio
import
com.infoloop.tianting.clientcustomerorderservice.BatchSaveSkuSellQuantitiesRpcRequest
;
import
com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrderDetailsRpcRequest
;
import
com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrderDetailsRpcResponse
;
import
com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrdersRpcRequest
;
import
com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderCreation
;
import
com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderDetailCreation
;
import
com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderDetailModification
;
...
...
@@ -43,6 +44,7 @@ import com.infoloop.tianting.clientcustomerorderservice.SkuSellQuantity;
import
com.infoloop.tianting.clientcustomerorderservice.SkuSellQuantityModification
;
import
com.infoloop.tianting.clientcustomerorderservice.UpdateClientCustomerOrderRpcRequest
;
import
com.infoloop.tianting.clientcustomerorderservice.UpdateClientCustomerOrderRpcResponse
;
import
com.infoloop.tianting.clientresourcetagservice.SingleResourceLabelEntityRefsResponse
;
import
com.infoloop.tianting.context.LoginContextHolder
;
import
com.infoloop.tianting.exception.ClientEndExceptions
;
import
com.infoloop.tianting.exception.ErrorCodeEnum
;
...
...
@@ -102,6 +104,7 @@ public class OrderServiceRpcClient {
private
final
MenuServiceRpcClient
menuServiceRpcClient
;
private
final
SkuServiceRpcClient
skuServiceRpcClient
;
private
final
OperatorServiceRpcClient
operatorServiceRpcClient
;
private
final
ClientResourceTagServiceRpcClient
clientResourceTagServiceRpcClient
;
private
final
RedissonClient
redissonClient
;
private
final
DelayedQueue
<
AutoCancelParam
>
delayedQueue
;
...
...
@@ -119,8 +122,7 @@ public class OrderServiceRpcClient {
GetClientCustomerOrdersByCustomerIdRpcRequest
.
newBuilder
().
setCustomerId
(
customerId
).
build
()).
getResponsesList
();
}
public
List
<
SingleClientCustomerOrderRpcResponse
>
getOrdersByCondition
(
QueryOrderByConditionDto
queryOrderDto
)
{
public
List
<
SingleClientCustomerOrderRpcResponse
>
getOrdersByCondition
(
QueryOrderByConditionDto
queryOrderDto
)
{
final
var
request
=
QueryClientCustomerOrdersByConditionRpcRequest
.
newBuilder
()
.
setEnterpriseId
(
queryOrderDto
.
getEnterpriseId
())
.
setShouldFilterOpenIds
(
queryOrderDto
.
getShouldFilterOpenId
())
...
...
@@ -145,6 +147,10 @@ public class OrderServiceRpcClient {
.
addAllMenuIds
(
List
.
of
(
queryOrderDto
.
getMenuId
()))
.
setShouldFilterOpenIds
(
queryOrderDto
.
getShouldFilterOpenId
())
.
addAllOpenIds
(
List
.
of
(
queryOrderDto
.
getOpenId
()))
.
setShouldFilterPayStatus
(
queryOrderDto
.
getShouldFilterPayStatus
())
.
setPayStatus
(
queryOrderDto
.
getPayStatus
())
.
setShouldFilterStatues
(
queryOrderDto
.
getShouldFilterStatues
())
.
addAllStatues
(
queryOrderDto
.
getStatues
())
.
build
();
return
orderServiceRpcBlockingStub
.
queryClientCustomerOrdersByCondition
(
request
).
getResponsesList
();
}
...
...
@@ -539,8 +545,11 @@ public class OrderServiceRpcClient {
.
build
();
final
var
menuById
=
menuServiceRpcClient
.
getMenuById
(
createOrderDto
.
getEnterpriseId
(),
createOrderDto
.
getMenuId
());
OrderStatusEnum
orderStatus
=
OrderStatusEnum
.
TO_PREPARE
;
if
(
menuById
.
getResponse
().
getOrderRuleJson
().
getModeOfPayment
()
==
ModeOfPaymentEnum
.
ONLINE
&&
menuById
.
getResponse
().
getOrderRuleJson
().
getCloseTimeType
()
==
CloseTimeTypeEnum
.
IMMEDIATELY
)
{
orderStatus
=
OrderStatusEnum
.
PREPARING
;
if
(
createOrderDto
.
getOnlinePay
()
!=
OnlinePayEnum
.
ONLINE
)
{
var
orderRuleJson
=
menuById
.
getResponse
().
getOrderRuleJson
();
if
(
orderRuleJson
.
getModeOfPayment
()
==
ModeOfPaymentEnum
.
ONLINE
&&
orderRuleJson
.
getCloseTimeType
()
==
CloseTimeTypeEnum
.
IMMEDIATELY
)
{
orderStatus
=
OrderStatusEnum
.
PREPARING
;
}
}
final
var
creation
=
ClientCustomerOrderCreation
.
newBuilder
()
.
setShouldCreateCustomerId
(
createOrderDto
.
getShouldCreateCustomerId
())
...
...
@@ -553,7 +562,7 @@ public class OrderServiceRpcClient {
.
setShouldCreateRoomNo
(!
createOrderDto
.
getRoomNo
().
isEmpty
()).
setRoomNo
(
createOrderDto
.
getRoomNo
())
.
setShouldCreateTableCode
(
createOrderDto
.
getCloseTimeType
().
equals
(
CloseTimeType
.
IMMEDIATELY
)
||
StringUtils
.
isNotEmpty
(
createOrderDto
.
getTableCode
())).
setTableCode
(
createOrderDto
.
getTableCode
()
==
null
?
""
:
createOrderDto
.
getTableCode
())
.
setShouldCreateOnlinePay
(
true
).
setOnlinePay
(
createOrderDto
.
getOnlinePay
())
.
setShouldCreatePayStatus
(
true
).
setPayStatus
(
createOrderDto
.
getOnlinePay
()
==
OnlinePayEnum
.
ONLINE
||
createOrderDto
.
getOnlinePay
()
==
OnlinePayEnum
.
LEAVE_HOSPITAL
?
PayStatusEnum
.
TO_PAY
:
PayStatusEnum
.
SUCCEED
)
.
setShouldCreatePayStatus
(
true
).
setPayStatus
(
createOrderDto
.
getOnlinePay
()
==
OnlinePayEnum
.
ONLINE
?
PayStatusEnum
.
TO_PAY
:
PayStatusEnum
.
SUCCEED
)
.
setMenuId
(
createOrderDto
.
getMenuId
())
.
setTotalNum
(
createOrderDto
.
getTotalNum
())
.
setShouldCreatePayPrice
(
createOrderDto
.
getOnlinePay
()
==
OnlinePayEnum
.
LEAVE_HOSPITAL
).
setPayPrice
(
createOrderDto
.
getPayPrice
())
...
...
@@ -571,13 +580,10 @@ public class OrderServiceRpcClient {
final
var
skuSellQuantities
=
this
.
querySkuSellQuantitiesByStallAndSkuIds
(
createOrderDto
.
getEnterpriseId
(),
createOrderDto
.
getStallId
(),
skuIds
);
final
var
skuSellQuantityMap
=
skuSellQuantities
.
stream
().
collect
(
Collectors
.
toMap
(
SingleSkuSellQuantityRpcResponse:
:
getSkuId
,
Function
.
identity
()));
final
var
skuMap
=
skuServiceRpcClient
.
getSkusByIds
(
skuIds
).
stream
().
collect
(
Collectors
.
toMap
(
SingleSkuResponse:
:
getId
,
Function
.
identity
()));
final
var
soldOutSkus
=
new
ArrayList
<
String
>();
final
var
skuStockMap
=
new
HashMap
<
String
,
Integer
>();
for
(
var
orderDetail
:
createOrderDto
.
getOrderDetailDtos
())
{
final
var
skuSellQuantityRpcResponse
=
skuSellQuantityMap
.
get
(
orderDetail
.
getSkuId
());
if
(
skuSellQuantityRpcResponse
==
null
)
{
log
.
error
(
"skuSellQuantityRpcResponse is null; stallId:{}, skuId:{}"
,
createOrderDto
.
getStallId
(),
orderDetail
.
getSkuId
());
soldOutSkus
.
add
(
skuMap
.
get
(
orderDetail
.
getSkuId
()).
getName
());
continue
;
}
if
((
skuSellQuantityRpcResponse
.
getTodaySellQuantity
()
+
orderDetail
.
getCount
())
>
skuSellQuantityRpcResponse
.
getMaxSellQuantity
())
{
...
...
@@ -585,9 +591,6 @@ public class OrderServiceRpcClient {
skuStockMap
.
put
(
skuMap
.
get
(
orderDetail
.
getSkuId
()).
getName
(),
skuSellQuantityRpcResponse
.
getMaxSellQuantity
()
-
skuSellQuantityRpcResponse
.
getTodaySellQuantity
());
}
}
if
(!
soldOutSkus
.
isEmpty
())
{
throw
ClientEndExceptions
.
BusinessException
.
build
(
ErrorCodeEnum
.
SKUS_SOLD_OUT_TODAY
,
String
.
join
(
","
,
soldOutSkus
));
}
if
(!
skuStockMap
.
isEmpty
())
{
final
var
noEnoughSkus
=
String
.
join
(
", "
,
skuStockMap
.
keySet
());
throw
ClientEndExceptions
.
BusinessException
.
build
(
ErrorCodeEnum
.
SKUS_STOCK_NO_ENOUGH_TODAY
,
noEnoughSkus
);
...
...
@@ -601,7 +604,8 @@ public class OrderServiceRpcClient {
.
build
());
if
(
orderResponse
.
getIsCreated
())
{
// 用餐时间为当天,并且非在线支付餐单,发送消息给客户端
if
(
createOrderDto
.
getMealTime
().
toLocalDate
().
equals
(
LocalDate
.
now
())
&&
menuById
.
getResponse
().
getOrderRuleJson
().
getModeOfPayment
()
==
ModeOfPaymentEnum
.
ONLINE
)
{
if
(
createOrderDto
.
getMealTime
().
toLocalDate
().
equals
(
LocalDate
.
now
())
&&
menuById
.
getResponse
().
getOrderRuleJson
().
getModeOfPayment
()
!=
ModeOfPaymentEnum
.
ONLINE
)
{
final
var
userIds
=
clientResourceTagServiceRpcClient
.
getOperatorIdsByStallIds
(
List
.
of
(
createOrderDto
.
getStallId
())).
stream
().
map
(
SingleResourceLabelEntityRefsResponse:
:
getEntityId
).
distinct
().
map
(
String:
:
valueOf
).
collect
(
Collectors
.
toList
());
final
var
orderCreateSuccessData
=
OrderCreateSuccessData
.
builder
()
.
orderId
(
orderResponse
.
getId
())
.
build
();
...
...
@@ -609,11 +613,11 @@ public class OrderServiceRpcClient {
.
type
(
MessageTypeEnum
.
ORDER
)
.
noticeType
(
NoticeTypeEnum
.
ORDER_CREATED
)
.
subject
(
NoticeTypeEnum
.
ORDER_CREATED
.
getDescription
())
.
message
(
"
您
下单成功啦,快去查看吧~"
)
.
message
(
"
有新的订单
下单成功啦,快去查看吧~"
)
.
data
(
orderCreateSuccessData
)
.
build
();
try
{
WebSocketServer
.
sendMessageByUserTypes
(
List
.
of
(
UserTypeEnum
.
CLIENT
,
UserTypeEnum
.
KDS
),
data
);
WebSocketServer
.
sendMessageByUserTypes
(
List
.
of
(
UserTypeEnum
.
CLIENT
,
UserTypeEnum
.
KDS
),
userIds
,
data
);
}
catch
(
IOException
e
)
{
log
.
error
(
"Failed to send message to user"
,
e
);
}
...
...
@@ -637,6 +641,15 @@ public class OrderServiceRpcClient {
return
CreateOrderResponse
.
builder
().
id
(
orderResponse
.
getId
()).
isCreated
(
true
).
build
();
}
public
boolean
batchUpdateClientCustomerOrders
(
LoginContextHolder
.
LoginInfo
loginInfo
,
List
<
ClientCustomerOrderModification
>
modifications
)
{
return
orderServiceRpcBlockingStub
.
batchUpdateClientCustomerOrders
(
BatchUpdateClientCustomerOrdersRpcRequest
.
newBuilder
()
.
setEnterpriseId
(
loginInfo
.
getEnterpriseId
())
.
setUpdatedBy
(
loginInfo
.
getId
())
.
setUpdateSource
(
OrderSourceEnum
.
forNumber
(
loginInfo
.
getLoginSource
().
getValue
()))
.
addAllModifications
(
modifications
)
.
build
()).
getIsUpdated
();
}
public
List
<
SingleSkuSellQuantityRpcResponse
>
querySkuSellQuantitiesByStall
(
int
enterpriseId
,
int
stallId
)
{
return
orderServiceRpcBlockingStub
.
querySkuSellQuantitiesByStall
(
QuerySkuSellQuantitiesByStallRpcRequest
.
newBuilder
()
...
...
src/main/java/com/infoloop/tianting/service/client/PayServiceClient.java
View file @
6cd094a
...
...
@@ -120,7 +120,7 @@ public class PayServiceClient {
}
}
public
boolean
callback
(
PaymentCallbackDTO
paymentCallbackDTO
)
{
public
boolean
callback
(
PaymentCallbackDTO
paymentCallbackDTO
)
{
log
.
info
(
"callback request received: {}"
,
paymentCallbackDTO
);
try
{
final
var
paymentCallbackResult
=
xmlMapper
.
readValue
(
paymentCallbackDTO
.
getPayResult
(),
PaymentCallbackResult
.
class
);
...
...
@@ -157,6 +157,7 @@ public class PayServiceClient {
.
setShouldUpdatePayTime
(
true
).
setPayTime
(
payTime
)
.
setShouldUpdatePayPrice
(
true
).
setPayPrice
(
realAmount
.
multiply
(
new
BigDecimal
(
"100"
)).
intValue
())
.
setShouldUpdatePayStatus
(
true
).
setPayStatus
(
PayStatusEnum
.
SUCCEED
)
.
setShouldUpdateStatus
(
true
).
setStatus
(
OrderStatusEnum
.
PREPARING
)
.
setShouldUpdateTransactionId
(
true
).
setTransactionId
(
paymentCallbackResult
.
getTransSN
())
.
build
();
final
var
updateResponse
=
orderServiceRpcClient
.
updateClientCustomerOrderPaymentResult
(
orderById
,
build
);
...
...
src/main/java/com/infoloop/tianting/service/impl/CategoriesServiceImpl.java
View file @
6cd094a
...
...
@@ -5,36 +5,34 @@ import com.infoloop.tianting.model.dto.CategoryDbDTO.CategoryDto;
import
com.infoloop.tianting.service.CategoriesService
;
import
com.infoloop.tianting.service.client.CategoriesServiceRpcClient
;
import
com.infoloop.tianting.utils.DateUtil
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Slf4j
@Service
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
CategoriesServiceImpl
implements
CategoriesService
{
private
final
CategoriesServiceRpcClient
categoriesServiceRpcClient
;
@Override
public
List
<
CategoryDto
>
queryCategoriesAll
()
{
final
var
operatorLoginInfo
=
LoginContextHolder
.
getLoginInfo
();
final
var
response
=
categoriesServiceRpcClient
.
queryCategoriesAll
(
operatorLoginInfo
.
getEnterpriseId
());
return
response
.
getResponsesList
().
stream
().
map
(
category
->
CategoryDto
.
builder
()
.
id
(
category
.
getId
())
.
enterpriseId
(
category
.
getEnterpriseId
())
.
code
(
category
.
getCode
())
.
name
(
category
.
getName
())
.
createdAt
(
DateUtil
.
formatDate
(
category
.
getCreatedAt
()))
.
updatedAt
(
DateUtil
.
formatDate
(
category
.
getUpdatedAt
()))
.
build
()
).
collect
(
Collectors
.
toList
());
}
private
final
CategoriesServiceRpcClient
categoriesServiceRpcClient
;
@Override
public
List
<
CategoryDto
>
queryCategoriesAll
()
{
final
var
operatorLoginInfo
=
LoginContextHolder
.
getLoginInfo
();
final
var
response
=
categoriesServiceRpcClient
.
queryCategoriesAll
(
operatorLoginInfo
.
getEnterpriseId
());
return
response
.
getResponsesList
().
stream
().
map
(
category
->
CategoryDto
.
builder
()
.
id
(
category
.
getId
())
.
enterpriseId
(
category
.
getEnterpriseId
())
.
code
(
category
.
getCode
())
.
name
(
category
.
getName
())
.
createdAt
(
DateUtil
.
formatDate
(
category
.
getCreatedAt
()))
.
updatedAt
(
DateUtil
.
formatDate
(
category
.
getUpdatedAt
()))
.
build
()
).
collect
(
Collectors
.
toList
());
}
}
...
...
src/main/java/com/infoloop/tianting/service/impl/ClientCustomerServiceImpl.java
View file @
6cd094a
...
...
@@ -3,6 +3,7 @@ package com.infoloop.tianting.service.impl;
import
com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse
;
import
com.infoloop.tianting.clientcustomerservice.SingleClientCustomerRpcResponse
;
import
com.infoloop.tianting.context.LoginContextHolder
;
import
com.infoloop.tianting.logic.async.HisCustomerRoomNoTask
;
import
com.infoloop.tianting.menuservice.SingleClientCustomerMenuRefRpcResponse
;
import
com.infoloop.tianting.model.dto.ClientCustomerDbDTO.ClientCustomerDto
;
import
com.infoloop.tianting.model.dto.ClientCustomerDbDTO.CurrentClientCustomerDto
;
...
...
@@ -29,9 +30,11 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.io.IOException
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.stream.Collectors
;
...
...
@@ -45,6 +48,7 @@ public class ClientCustomerServiceImpl implements ClientCustomerService {
private
final
ClientCustomerServiceHttpClient
clientCustomerServiceHttpClient
;
private
final
OrderServiceRpcClient
orderServiceRpcClient
;
private
final
MenuServiceRpcClient
menuServiceRpcClient
;
private
final
HisCustomerRoomNoTask
hisCustomerRoomNoTask
;
@Override
public
ClientCustomerDto
getClientCustomerByHISCustomerId
(
String
hisCustomerId
)
{
...
...
@@ -137,10 +141,8 @@ public class ClientCustomerServiceImpl implements ClientCustomerService {
}
@Override
public
List
<
HospitalRecordDto
>
getClientCustomerHospitalRecordsByCustomerId
(
Integer
enterpriseId
,
Integer
customerId
)
{
final
var
response
=
clientCustomerServiceRpcClient
.
getClientCustomerHospitalRecordsByCustomerId
(
enterpriseId
,
customerId
);
public
List
<
HospitalRecordDto
>
getClientCustomerHospitalRecordsByCustomerId
(
Integer
enterpriseId
,
Integer
customerId
)
{
final
var
response
=
clientCustomerServiceRpcClient
.
getClientCustomerHospitalRecordsByCustomerId
(
enterpriseId
,
customerId
);
final
var
record
=
response
.
getResponse
();
return
List
.
of
(
HospitalRecordDto
.
builder
()
.
id
(
record
.
getId
())
...
...
@@ -169,10 +171,8 @@ public class ClientCustomerServiceImpl implements ClientCustomerService {
}
@Override
public
BatchCreateCustomerLabelRefResponseDto
batchCreateClientCustomerLabelRefs
(
BatchCreateCustomerLabelRefDto
batchCreateCustomerLabelRefDto
)
{
final
var
response
=
clientCustomerServiceRpcClient
.
batchCreateClientCustomerLabelRefs
(
batchCreateCustomerLabelRefDto
);
public
BatchCreateCustomerLabelRefResponseDto
batchCreateClientCustomerLabelRefs
(
BatchCreateCustomerLabelRefDto
batchCreateCustomerLabelRefDto
)
{
final
var
response
=
clientCustomerServiceRpcClient
.
batchCreateClientCustomerLabelRefs
(
batchCreateCustomerLabelRefDto
);
return
BatchCreateCustomerLabelRefResponseDto
.
builder
()
.
isCreated
(
response
.
getIsCreated
())
.
ids
(
response
.
getIdsList
())
...
...
@@ -180,11 +180,8 @@ public class ClientCustomerServiceImpl implements ClientCustomerService {
}
@Override
public
List
<
CustomerLabelRefDetailDto
>
getCustomerLabelsByCustomerId
(
Integer
enterpriseId
,
Integer
customerId
)
{
final
var
response
=
clientCustomerServiceRpcClient
.
getCustomerLabelsByCustomerId
(
enterpriseId
,
customerId
);
public
List
<
CustomerLabelRefDetailDto
>
getCustomerLabelsByCustomerId
(
Integer
enterpriseId
,
Integer
customerId
)
{
final
var
response
=
clientCustomerServiceRpcClient
.
getCustomerLabelsByCustomerId
(
enterpriseId
,
customerId
);
return
response
.
getResponsesList
().
stream
().
map
(
labelRef
->
CustomerLabelRefDetailDto
.
builder
()
.
id
(
labelRef
.
getId
())
...
...
@@ -199,120 +196,15 @@ public class ClientCustomerServiceImpl implements ClientCustomerService {
}
@Override
public
BatchDeleteCustomerLabelRefResponseDto
deleteClientCustomerLabelRefsByIds
(
BatchDeleteCustomerLabelRefRequestDto
deleteRequestDto
)
{
final
var
response
=
clientCustomerServiceRpcClient
.
batchDeleteClientCustomerLabelRefsByIds
(
deleteRequestDto
);
public
BatchDeleteCustomerLabelRefResponseDto
deleteClientCustomerLabelRefsByIds
(
BatchDeleteCustomerLabelRefRequestDto
deleteRequestDto
)
{
final
var
response
=
clientCustomerServiceRpcClient
.
batchDeleteClientCustomerLabelRefsByIds
(
deleteRequestDto
);
return
BatchDeleteCustomerLabelRefResponseDto
.
builder
().
isDeleted
(
response
.
getIsDeleted
()).
build
();
}
// @Override
// public TodayOrderDto getTodayOrderStatistic(String token) {
// final var currentCustomers = clientCustomerServiceHttpClient.getCurrentClientCustomer(token, false);
// final var customerIds = currentCustomers.stream().map(CurrentClientCustomerDto::getId).map(id -> {try{
// return Integer.valueOf(id);
// } catch (NumberFormatException e) {
// return null;
// }
// }).filter(Objects::nonNull).distinct().collect(Collectors.toList());
// final var operatorLoginInfo = LoginContextHolder.getLoginInfo();
// LocalDate today = LocalDate.now();
// LocalDateTime todayZero = today.atStartOfDay();
// LocalDate tomorrow = today.plusDays(1);
// LocalDateTime tomorrowZero = tomorrow.atStartOfDay();
// final var queryOrderDto = QueryOrderByConditionDto.builder()
// .enterpriseId(operatorLoginInfo.getEnterpriseId())
// .shouldFilterCustomerIds(true)
// .customerIds(customerIds)
// .shouldFilterMealTimeStart(true)
// .mealTimeStart(todayZero)
// .shouldFilterMealTimeEnd(true)
// .mealTimeEnd(tomorrowZero)
// .build();
// final var orderedResponseList = orderServiceRpcClient.getOrdersByCondition(queryOrderDto);
// List<Integer> uniqueOrderedCustomerIds = orderedResponseList.stream().map(
// SingleClientCustomerOrderRpcResponse::getCustomerId).distinct()
// .collect(Collectors.toList());
// List<Integer> notOrderedCustomerIds = customerIds.stream().filter(id -> !uniqueOrderedCustomerIds.contains(id)).collect(
// Collectors.toList());
// // 根据customerIds 获取到menuRef列表
// final var menuRefs = menuServiceRpcClient.getClientCustomerMenuRefsByCustomerIds(
// operatorLoginInfo.getEnterpriseId(), notOrderedCustomerIds).getResponsesList();
// final var menuIds = menuRefs.stream().map(SingleClientCustomerMenuRefRpcResponse::getMenuId)
// .collect(Collectors.toList());
// final var menus = menuServiceRpcClient.getMenusByIds(operatorLoginInfo.getEnterpriseId(),
// menuIds).getResponsesList();
//
// List<NotOrderCustomerDto> resNotOrderCustomers = new ArrayList<>();
// // 在customers里找到未下单的用户
// final var notOrderCustomers = currentCustomers.stream().filter(c ->
// notOrderedCustomerIds.contains(Integer.valueOf(c.getId()))).collect(Collectors.toList());
//
// for(CurrentClientCustomerDto notOrderCustomer: notOrderCustomers) {
//
// // 在ref里找到这个用户的menu ids
// final var notOrderCustomerId = Integer.valueOf(notOrderCustomer.getId());
// final var curMenuIds = menuRefs.stream().filter(r -> r.getCustomerId() == notOrderCustomerId)
// .map(SingleClientCustomerMenuRefRpcResponse::getMenuId).collect(Collectors.toList());
// // 根据menu ids找到 menus
// final var curMenus = menus.stream().filter(m -> curMenuIds.contains(m.getId()))
// .collect(Collectors.toList());
//
// final var curMenuDtos = curMenus.stream().map(menu ->
// MenuDto.builder()
// .id(menu.getId())
// .code(menu.getCode())
// .enterpriseId(menu.getEnterpriseId())
// .name(menu.getName())
// .status(menu.getStatusValue())
// .customerScope(menu.getCustomerScope())
// .nutritionPromotion(menu.getNutritionPromotion())
// .nutritionalStatistics(menu.getNutritionalStatistics())
// .dishRuleJson(DishRuleJson.builder()
// .days(menu.getDishRuleJson().getDays())
// .dishType(menu.getDishRuleJson().getDishType())
// .mealIds(menu.getDishRuleJson().getMealIdsList())
// .build())
// .orderRuleJson(OrderRuleJson.builder()
// .allowMicroPlaceOrder(menu.getOrderRuleJson().getAllowMicroPlaceOrder())
// .closeTimeType(menu.getOrderRuleJson().getCloseTimeType())
// .dishSelectRule(menu.getOrderRuleJson().getDishSelectRule())
// .earlyDays(menu.getOrderRuleJson().getEarlyDays())
// .modeOfPayment(menu.getOrderRuleJson().getModeOfPayment())
// .placeOrderCount(menu.getOrderRuleJson().getPlaceOrderCount())
// .startTime(menu.getOrderRuleJson().getStartTime())
// .endTime(menu.getOrderRuleJson().getEndTime())
// .deadline(menu.getOrderRuleJson().getDeadline())
// .build())
// .createdBy(menu.getCreatedBy())
// .creationSource(menu.getCreationSource())
// .createdAt(DateUtil.formatDate(menu.getCreatedAt()))
// .updatedBy(menu.getUpdatedBy())
// .updateSource(menu.getUpdateSource())
// .updatedAt(DateUtil.formatDate(menu.getUpdatedAt()))
// .publishAt(DateUtil.formatDate(menu.getPublishAt()))
// .build()).collect(Collectors.toList());
// final var resNotOrderCustomer = NotOrderCustomerDto.builder()
// .id(notOrderCustomerId)
// .name(notOrderCustomer.getName())
// .roomNo(notOrderCustomer.getRoomNo())
// .menuList(curMenuDtos)
// .build();
// resNotOrderCustomers.add(resNotOrderCustomer);
// }
//
// return TodayOrderDto.builder()
// .totalCurrentCustomerCount(currentCustomers.size())
// .notOrderCustomers(resNotOrderCustomers)
// .build();
// }
@Override
public
TodayOrderDto
getTodayOrderStatistic
(
String
token
)
{
List
<
CurrentClientCustomerDto
>
currentCustomers
=
new
ArrayList
<>();
List
<
Integer
>
customerIds
=
new
ArrayList
<>();
currentCustomers
=
clientCustomerServiceHttpClient
.
getCurrentClientCustomer
(
token
,
false
);
customerIds
=
currentCustomers
.
stream
().
map
(
CurrentClientCustomerDto:
:
getId
).
map
(
id
->
{
List
<
CurrentClientCustomerDto
>
currentCustomers
=
clientCustomerServiceHttpClient
.
getCurrentClientCustomer
(
token
,
false
);
List
<
Integer
>
customerIds
=
currentCustomers
.
stream
().
map
(
CurrentClientCustomerDto:
:
getId
).
map
(
id
->
{
try
{
return
Integer
.
valueOf
(
id
);
}
catch
(
NumberFormatException
e
)
{
...
...
@@ -421,26 +313,17 @@ public class ClientCustomerServiceImpl implements ClientCustomerService {
@Override
public
TodayOrderDto
getTodayOrderStatisticForHis
(
String
token
)
{
List
<
CurrentClientCustomerDto
>
currentCustomers
=
new
ArrayList
<>();
List
<
Integer
>
customerIds
=
new
ArrayList
<>();
// 没有找到clientCustomer的hisCustomerIds
List
<
CurrentClientCustomerDto
>
notOrderedHisCustomers
=
new
ArrayList
<>();
currentCustomers
=
clientCustomerServiceHttpClient
.
getCurrentClientCustomer
(
token
,
true
);
final
var
hisCustomerIds
=
currentCustomers
.
stream
().
map
(
CurrentClientCustomerDto:
:
getId
).
distinct
()
.
collect
(
Collectors
.
toList
());
final
var
currentCustomers
=
clientCustomerServiceHttpClient
.
getCurrentClientCustomer
(
token
,
true
);
final
var
hisCustomerIds
=
currentCustomers
.
stream
().
map
(
CurrentClientCustomerDto:
:
getId
).
distinct
().
collect
(
Collectors
.
toList
());
final
var
currentClientCustomers
=
clientCustomerServiceRpcClient
.
getClientCustomersByHISCustomerIds
(
hisCustomerIds
).
getResponsesList
();
customerIds
=
currentClientCustomers
.
stream
().
map
(
SingleClientCustomerRpcResponse:
:
getId
).
distinct
().
collect
(
Collectors
.
toList
());
final
var
customerIds
=
currentClientCustomers
.
stream
().
map
(
SingleClientCustomerRpcResponse:
:
getId
).
distinct
().
collect
(
Collectors
.
toList
());
final
var
mappingHisCustomerIds
=
currentClientCustomers
.
stream
().
map
(
SingleClientCustomerRpcResponse:
:
getHISCustomerId
).
collect
(
Collectors
.
toList
());
// final var notOrderedHisCustomerIds = hisCustomerIds.stream().filter(i -> !mappingHisCustomerIds.contains(i)).collect(Collectors.toList());
notOrderedHisCustomers
=
currentCustomers
.
stream
().
filter
(
c
->
!
mappingHisCustomerIds
.
contains
(
c
.
getId
())).
collect
(
Collectors
.
toList
());
final
var
notOrderedHisCustomers
=
currentCustomers
.
stream
().
filter
(
c
->
!
mappingHisCustomerIds
.
contains
(
c
.
getId
())).
collect
(
Collectors
.
toList
());
final
var
operatorLoginInfo
=
LoginContextHolder
.
getLoginInfo
();
LocalDate
today
=
LocalDate
.
now
();
LocalDateTime
todayZero
=
today
.
atStartOfDay
();
LocalDate
tomorrow
=
today
.
plusDays
(
1
);
LocalDateTime
tomorrowZero
=
tomorrow
.
atStartOfDay
();
final
var
today
=
LocalDate
.
now
();
final
var
todayZero
=
today
.
atStartOfDay
();
final
var
tomorrow
=
today
.
plusDays
(
1
);
final
var
tomorrowZero
=
tomorrow
.
atStartOfDay
();
final
var
queryOrderDto
=
QueryOrderByConditionDto
.
builder
()
.
enterpriseId
(
operatorLoginInfo
.
getEnterpriseId
())
.
shouldFilterCustomerIds
(
true
)
...
...
@@ -450,39 +333,25 @@ public class ClientCustomerServiceImpl implements ClientCustomerService {
.
shouldFilterMealTimeEnd
(
true
)
.
mealTimeEnd
(
tomorrowZero
)
.
build
();
List
<
SingleClientCustomerOrderRpcResponse
>
orderedResponseList
=
new
ArrayList
<>();
if
(!
customerIds
.
isEmpty
())
{
orderedResponseList
=
orderServiceRpcClient
.
getOrdersByCondition
(
queryOrderDto
);
}
List
<
Integer
>
uniqueOrderedCustomerIds
=
orderedResponseList
.
stream
().
map
(
SingleClientCustomerOrderRpcResponse:
:
getCustomerId
).
distinct
()
.
collect
(
Collectors
.
toList
());
List
<
Integer
>
notOrderedCustomerIds
=
customerIds
.
stream
().
filter
(
id
->
!
uniqueOrderedCustomerIds
.
contains
(
id
)).
collect
(
Collectors
.
toList
());
List
<
Integer
>
uniqueOrderedCustomerIds
=
orderedResponseList
.
stream
().
map
(
SingleClientCustomerOrderRpcResponse:
:
getCustomerId
).
distinct
().
collect
(
Collectors
.
toList
());
List
<
Integer
>
notOrderedCustomerIds
=
customerIds
.
stream
().
filter
(
id
->
!
uniqueOrderedCustomerIds
.
contains
(
id
)).
collect
(
Collectors
.
toList
());
// 根据customerIds 获取到menuRef列表
final
var
menuRefs
=
menuServiceRpcClient
.
getClientCustomerMenuRefsByCustomerIds
(
operatorLoginInfo
.
getEnterpriseId
(),
notOrderedCustomerIds
).
getResponsesList
();
final
var
menuIds
=
menuRefs
.
stream
().
map
(
SingleClientCustomerMenuRefRpcResponse:
:
getMenuId
)
.
collect
(
Collectors
.
toList
());
final
var
menus
=
menuServiceRpcClient
.
getMenusByIds
(
operatorLoginInfo
.
getEnterpriseId
(),
menuIds
).
getResponsesList
();
final
var
menuRefs
=
menuServiceRpcClient
.
getClientCustomerMenuRefsByCustomerIds
(
operatorLoginInfo
.
getEnterpriseId
(),
notOrderedCustomerIds
).
getResponsesList
();
final
var
menuIds
=
menuRefs
.
stream
().
map
(
SingleClientCustomerMenuRefRpcResponse:
:
getMenuId
).
collect
(
Collectors
.
toList
());
final
var
menus
=
menuServiceRpcClient
.
getMenusByIds
(
operatorLoginInfo
.
getEnterpriseId
(),
menuIds
).
getResponsesList
();
List
<
NotOrderCustomerDto
>
resNotOrderCustomers
=
new
ArrayList
<>();
// 在customers里找到未下单的用户
final
var
notOrderCustomers
=
currentClientCustomers
.
stream
().
filter
(
c
->
notOrderedCustomerIds
.
contains
(
c
.
getId
())).
collect
(
Collectors
.
toList
());
final
var
notOrderCustomers
=
currentClientCustomers
.
stream
().
filter
(
c
->
notOrderedCustomerIds
.
contains
(
c
.
getId
())).
collect
(
Collectors
.
toList
());
for
(
SingleClientCustomerRpcResponse
notOrderCustomer
:
notOrderCustomers
)
{
// 在ref里找到这个用户的menu ids
final
var
notOrderCustomerId
=
Integer
.
valueOf
(
notOrderCustomer
.
getId
());
final
var
curMenuIds
=
menuRefs
.
stream
().
filter
(
r
->
r
.
getCustomerId
()
==
notOrderCustomerId
)
.
map
(
SingleClientCustomerMenuRefRpcResponse:
:
getMenuId
).
collect
(
Collectors
.
toList
());
final
var
curMenuIds
=
menuRefs
.
stream
().
filter
(
r
->
r
.
getCustomerId
()
==
notOrderCustomerId
).
map
(
SingleClientCustomerMenuRefRpcResponse:
:
getMenuId
).
collect
(
Collectors
.
toList
());
// 根据menu ids找到 menus
final
var
curMenus
=
menus
.
stream
().
filter
(
m
->
curMenuIds
.
contains
(
m
.
getId
()))
.
collect
(
Collectors
.
toList
());
final
var
curMenus
=
menus
.
stream
().
filter
(
m
->
curMenuIds
.
contains
(
m
.
getId
())).
collect
(
Collectors
.
toList
());
final
var
curMenuDtos
=
curMenus
.
stream
().
map
(
menu
->
MenuDto
.
builder
()
.
id
(
menu
.
getId
())
...
...
@@ -531,12 +400,12 @@ public class ClientCustomerServiceImpl implements ClientCustomerService {
resNotOrderCustomers
.
add
(
resNotOrderCustomer
);
}
for
(
CurrentClientCustomerDto
currentClientCustomer
:
notOrderedHisCustomers
)
{
for
(
final
var
currentClientCustomer
:
notOrderedHisCustomers
)
{
final
var
resNotOrderCustomer
=
NotOrderCustomerDto
.
builder
()
.
id
(
currentClientCustomer
.
getId
())
.
name
(
currentClientCustomer
.
getName
())
.
roomNo
(
currentClientCustomer
.
getRoomNo
())
.
menuList
(
new
ArrayList
<>
())
.
menuList
(
Collections
.
emptyList
())
.
build
();
resNotOrderCustomers
.
add
(
resNotOrderCustomer
);
}
...
...
@@ -575,4 +444,9 @@ public class ClientCustomerServiceImpl implements ClientCustomerService {
.
build
();
}
@Override
public
void
synchronizationHisClientCustomer
()
throws
IOException
{
hisCustomerRoomNoTask
.
synchronization
(
LoginContextHolder
.
getLoginInfo
());
}
}
...
...
src/main/java/com/infoloop/tianting/service/impl/DeliveryRuleServiceImpl.java
View file @
6cd094a
package
com
.
infoloop
.
tianting
.
service
.
impl
;
import
com.infoloop.tianting.deliveryruleservice.ClientLabelTypeEnum
;
import
com.infoloop.tianting.model.dto.ClientLabelDTO.LabelDto
;
import
com.infoloop.tianting.model.dto.ClientLabelDTO.QueryLabelsDto
;
import
com.infoloop.tianting.service.DeliveryRuleService
;
import
com.infoloop.tianting.service.client.DeliveryRuleServiceRpcClient
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Slf4j
@Service
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
DeliveryRuleServiceImpl
implements
DeliveryRuleService
{
private
final
DeliveryRuleServiceRpcClient
deliveryRuleServiceRpcClient
;
@Override
public
List
<
LabelDto
>
getLabelsByTypes
(
QueryLabelsDto
queryLabelsDto
)
{
private
final
DeliveryRuleServiceRpcClient
deliveryRuleServiceRpcClient
;
final
var
response
=
deliveryRuleServiceRpcClient
.
getLabelsByTypes
(
queryLabelsDto
);
return
response
.
getResponsesList
().
stream
().
map
(
label
->
LabelDto
.
builder
()
.
id
(
label
.
getId
())
.
code
(
label
.
getCode
())
.
name
(
label
.
getName
())
.
enterpriseId
(
label
.
getEnterpriseId
())
.
isDefault
(
label
.
getIsDefault
())
.
remark
(
label
.
getRemark
())
.
status
(
label
.
getStatus
())
.
type
(
label
.
getType
())
.
build
()
).
collect
(
Collectors
.
toList
());
}
@Override
public
List
<
LabelDto
>
getLabelsByTypes
(
QueryLabelsDto
queryLabelsDto
)
{
final
var
response
=
deliveryRuleServiceRpcClient
.
getLabelsByTypes
(
queryLabelsDto
);
return
response
.
getResponsesList
().
stream
().
map
(
label
->
LabelDto
.
builder
()
.
id
(
label
.
getId
())
.
code
(
label
.
getCode
())
.
name
(
label
.
getName
())
.
enterpriseId
(
label
.
getEnterpriseId
())
.
isDefault
(
label
.
getIsDefault
())
.
remark
(
label
.
getRemark
())
.
status
(
label
.
getStatus
())
.
type
(
label
.
getType
())
.
build
()
).
collect
(
Collectors
.
toList
());
}
}
...
...
src/main/java/com/infoloop/tianting/service/impl/InventoryServiceImpl.java
View file @
6cd094a
...
...
@@ -68,10 +68,8 @@ public class InventoryServiceImpl implements InventoryService {
}
@Override
public
List
<
ClientTableCodeDto
>
queryClientTableCodesByCondition
(
TableCodeQueryConditionDto
tableCodeQueryConditionDto
)
{
final
var
response
=
inventoryServiceRpcClient
.
queryClientTableCodesByCondition
(
tableCodeQueryConditionDto
);
public
List
<
ClientTableCodeDto
>
queryClientTableCodesByCondition
(
TableCodeQueryConditionDto
tableCodeQueryConditionDto
)
{
final
var
response
=
inventoryServiceRpcClient
.
queryClientTableCodesByCondition
(
tableCodeQueryConditionDto
);
return
response
.
getResponsesList
().
stream
().
map
(
tableCode
->
ClientTableCodeDto
.
builder
()
.
id
(
tableCode
.
getId
())
...
...
src/main/java/com/infoloop/tianting/service/impl/KdsServiceImpl.java
View file @
6cd094a
package
com
.
infoloop
.
tianting
.
service
.
impl
;
import
com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum
;
import
com.infoloop.tianting.clientcustomerorderservice.PayStatusEnum
;
import
com.infoloop.tianting.clientcustomerorderservice.ServeStatusEnum
;
import
com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderDetailRpcResponse
;
import
com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse
;
...
...
@@ -51,24 +52,20 @@ public class KdsServiceImpl implements KdsService {
@Override
public
List
<
KdsOrderSkuDto
>
getOrderDetailBySku
(
KdsOrderSkuQueryDto
queryDto
)
{
// 获取当日所有的订单 和 订单明细
LocalDate
today
=
LocalDate
.
now
();
LocalDateTime
todayZero
=
today
.
atStartOfDay
();
LocalDate
tomorrow
=
today
.
plusDays
(
1
);
LocalDateTime
tomorrowZero
=
tomorrow
.
atStartOfDay
();
final
var
operatorLoginInfo
=
LoginContextHolder
.
getLoginInfo
();
boolean
shouldFilterStallIds
=
false
;
List
<
Integer
>
stallIds
=
new
ArrayList
<>();
final
var
operator
=
wOperatorServiceRpcClient
.
getWOperatorById
(
operatorLoginInfo
.
getId
()).
getResponse
();
if
(!
operator
.
getIsSuper
())
{
shouldFilterStallIds
=
true
;
final
var
userResource
=
enterpriseResourceServiceRpcClient
.
getUserResources
(
operatorLoginInfo
.
getEnterpriseId
(),
operatorLoginInfo
.
getId
());
final
var
userResource
=
enterpriseResourceServiceRpcClient
.
getUserResources
(
operatorLoginInfo
.
getEnterpriseId
(),
operatorLoginInfo
.
getId
());
stallIds
.
addAll
(
userResource
.
getStallIdsList
());
}
final
var
queryOrderDto
=
QueryOrderByConditionDto
.
builder
()
.
enterpriseId
(
operatorLoginInfo
.
getEnterpriseId
())
.
shouldFilterStallIds
(
shouldFilterStallIds
)
...
...
@@ -77,6 +74,8 @@ public class KdsServiceImpl implements KdsService {
.
mealTimeStart
(
todayZero
)
.
shouldFilterMealTimeEnd
(
true
)
.
mealTimeEnd
(
tomorrowZero
)
.
shouldFilterPayStatus
(
true
)
.
payStatus
(
PayStatusEnum
.
SUCCEED
)
.
build
();
final
var
orderList
=
orderServiceRpcClient
.
getOrdersByCondition
(
queryOrderDto
);
List
<
Integer
>
orderIds
=
orderList
.
stream
()
...
...
@@ -170,7 +169,7 @@ public class KdsServiceImpl implements KdsService {
.
orderDetailId
(
detail
.
getId
())
.
remark
(
order
.
get
().
getRemark
())
.
orderId
(
order
.
get
().
getId
())
.
roomNo
(
order
.
get
().
getRoomNo
())
.
roomNo
(
order
.
get
().
get
SyncRoomNo
().
isEmpty
()
?
order
.
get
().
getRoomNo
()
:
order
.
get
().
getSync
RoomNo
())
.
tableCode
(
order
.
get
().
getTableCode
())
.
customerNotice
(
CustomerNotice
.
builder
()
.
doctors
(
order
.
get
().
getCustomerNoticeJson
().
getDoctorsList
())
...
...
@@ -309,6 +308,8 @@ public class KdsServiceImpl implements KdsService {
.
mealTimeEnd
(
tomorrowZero
)
.
shouldFilterStatus
(
true
)
.
status
(
queryDto
.
getOrderStatus
())
.
shouldFilterPayStatus
(
true
)
.
payStatus
(
PayStatusEnum
.
SUCCEED
)
.
build
();
final
var
orderList
=
orderServiceRpcClient
.
getOrdersByCondition
(
queryOrderDto
);
...
...
@@ -338,13 +339,6 @@ public class KdsServiceImpl implements KdsService {
final
var
filteredOrderDetailList
=
orderDetailList
.
stream
()
.
filter
(
od
->
od
.
getMealId
()
==
queryDto
.
getMealId
()
&&
od
.
getServeStatus
()
!=
ServeStatusEnum
.
SERVE_REJECT
)
.
collect
(
Collectors
.
toList
());
//在所有的orderDetail里找出所有所有不同的menuDetailId,然后根据menuDetailId进行分类
final
var
menuDetailIds
=
filteredOrderDetailList
.
stream
()
.
map
(
SingleClientCustomerOrderDetailRpcResponse:
:
getMenuDetailId
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
List
<
KdsOrderLocationDto
>
kdsOrderLocationList
=
new
ArrayList
<>();
for
(
SingleClientCustomerOrderRpcResponse
order
:
orderList
)
{
...
...
@@ -402,7 +396,7 @@ public class KdsServiceImpl implements KdsService {
.
totalCount
(
order
.
getTotalNum
())
.
remark
(
order
.
getRemark
())
.
orderId
(
order
.
getId
())
.
roomNo
(
order
.
getRoomNo
())
.
roomNo
(
order
.
get
SyncRoomNo
().
isEmpty
()
?
order
.
getRoomNo
()
:
order
.
getSync
RoomNo
())
.
tableCode
(
order
.
getTableCode
())
.
customerNotice
(
CustomerNotice
.
builder
()
.
doctors
(
order
.
getCustomerNoticeJson
().
getDoctorsList
())
...
...
src/main/java/com/infoloop/tianting/service/impl/LoginServiceImpl.java
View file @
6cd094a
...
...
@@ -3,6 +3,8 @@ package com.infoloop.tianting.service.impl;
import
cn.dev33.satoken.stp.SaLoginModel
;
import
cn.dev33.satoken.stp.SaTokenInfo
;
import
cn.dev33.satoken.stp.StpUtil
;
import
com.infoloop.rpc.meizhongyiheservice.HospitalStatus
;
import
com.infoloop.tianting.WOperatorStatus
;
import
com.infoloop.tianting.clientcustomerservice.ClientCustomerHospitalRecordHospitalStatusEnum
;
import
com.infoloop.tianting.constant.CommonConstants
;
import
com.infoloop.tianting.exception.ClientEndExceptions
;
...
...
@@ -10,6 +12,7 @@ import com.infoloop.tianting.exception.ErrorCodeEnum;
import
com.infoloop.tianting.model.dto.PermissionDTO.LoginDto
;
import
com.infoloop.tianting.service.LoginService
;
import
com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient
;
import
com.infoloop.tianting.service.client.MeiZhongYiHeServiceClient
;
import
com.infoloop.tianting.service.client.OperatorServiceRpcClient
;
import
com.infoloop.tianting.service.client.WOperatorServiceRpcClient
;
import
com.infoloop.tianting.service.client.WxMiniProgramHttpClient
;
...
...
@@ -30,6 +33,7 @@ public class LoginServiceImpl implements LoginService {
private
final
OperatorServiceRpcClient
operatorServiceRpcClient
;
private
final
WxMiniProgramHttpClient
wxMiniProgramHttpClient
;
private
final
WOperatorServiceRpcClient
wOperatorServiceRpcClient
;
private
final
MeiZhongYiHeServiceClient
meiZhongYiHeServiceClient
;
@Override
public
SaTokenInfo
login
(
LoginDto
loginDto
)
throws
NoSuchAlgorithmException
{
...
...
@@ -58,6 +62,11 @@ public class LoginServiceImpl implements LoginService {
if
(!
record
.
hasResponse
()
||
record
.
getResponse
().
getHospitalStatus
()
!=
ClientCustomerHospitalRecordHospitalStatusEnum
.
CURRENT
)
{
throw
ClientEndExceptions
.
IncorrectRequestValue
.
build
(
ErrorCodeEnum
.
VALIDATE_FAILED
.
name
());
}
//还需要去读取HIS系统最新用户住院信息
final
var
hisCustomerHospitalRecord
=
meiZhongYiHeServiceClient
.
getCustomerDetailById
(
customer
.
getHISCustomerId
(),
record
.
getResponse
().
getContractNo
()).
getCustomerHospitalRecord
();
if
(
hisCustomerHospitalRecord
.
getHospitalStatus
()
!=
HospitalStatus
.
CURRENT
)
{
throw
ClientEndExceptions
.
IncorrectRequestValue
.
build
(
ErrorCodeEnum
.
VALIDATE_FAILED
.
name
());
}
}
final
var
wxUserOpenIdDto
=
wxMiniProgramHttpClient
.
getUserOpenIdByCode
(
loginDto
.
getOpenCode
());
StpUtil
.
login
(
customer
.
getId
(),
SaLoginModel
.
create
()
...
...
@@ -74,6 +83,9 @@ public class LoginServiceImpl implements LoginService {
if
(!
operator
.
getPassword
().
equals
(
sha1Hash
(
loginDto
.
getPassword
())))
{
throw
ClientEndExceptions
.
AuthenticationFailure
.
build
(
ErrorCodeEnum
.
VALIDATE_FAILED
.
name
());
}
if
(
operator
.
getStatus
()
!=
1
)
{
throw
ClientEndExceptions
.
AuthenticationFailure
.
build
(
ErrorCodeEnum
.
VALIDATE_FAILED
.
name
());
}
StpUtil
.
login
(
operator
.
getId
(),
SaLoginModel
.
create
()
.
setExtra
(
CommonConstants
.
ENTERPRISE_ID
,
operator
.
getEnterpriseId
())
.
setExtra
(
CommonConstants
.
LOGIN_SOURCE
,
loginDto
.
getLoginSourceEnum
().
getValue
())
...
...
@@ -87,6 +99,9 @@ public class LoginServiceImpl implements LoginService {
if
(!
operator
.
getPassword
().
equals
(
sha1Hash
(
loginDto
.
getPassword
())))
{
throw
ClientEndExceptions
.
AuthenticationFailure
.
build
(
ErrorCodeEnum
.
VALIDATE_FAILED
.
name
());
}
if
(
operator
.
getStatus
()
!=
WOperatorStatus
.
SHOW
)
{
throw
ClientEndExceptions
.
AuthenticationFailure
.
build
(
ErrorCodeEnum
.
VALIDATE_FAILED
.
name
());
}
StpUtil
.
login
(
operator
.
getId
(),
SaLoginModel
.
create
()
.
setExtra
(
CommonConstants
.
ENTERPRISE_ID
,
operator
.
getEnterpriseId
())
.
setExtra
(
CommonConstants
.
LOGIN_SOURCE
,
loginDto
.
getLoginSourceEnum
().
getValue
())
...
...
src/main/java/com/infoloop/tianting/service/impl/MenuServiceImpl.java
View file @
6cd094a
...
...
@@ -30,8 +30,7 @@ public class MenuServiceImpl implements MenuService {
@Override
public
List
<
MenuDto
>
queryMiniProgramPublishedMenusByStallId
(
Integer
enterpriseId
,
Integer
stallId
)
{
final
var
response
=
menuServiceRpcClient
.
queryMiniProgramPublishedMenusByStallId
(
enterpriseId
,
stallId
);
final
var
response
=
menuServiceRpcClient
.
queryMiniProgramPublishedMenusByStallId
(
enterpriseId
,
stallId
);
return
response
.
getResponsesList
().
stream
().
map
(
menu
->
MenuDto
.
builder
()
.
id
(
menu
.
getId
())
...
...
@@ -69,10 +68,8 @@ public class MenuServiceImpl implements MenuService {
}
@Override
public
List
<
MenuDto
>
queryPublishedMenusByStallId
(
Integer
enterpriseId
,
Integer
stallId
)
{
final
var
response
=
menuServiceRpcClient
.
queryPublishedMenusByStallId
(
enterpriseId
,
stallId
);
public
List
<
MenuDto
>
queryPublishedMenusByStallId
(
Integer
enterpriseId
,
Integer
stallId
)
{
final
var
response
=
menuServiceRpcClient
.
queryPublishedMenusByStallId
(
enterpriseId
,
stallId
);
return
response
.
getResponsesList
().
stream
().
map
(
menu
->
MenuDto
.
builder
()
.
id
(
menu
.
getId
())
...
...
src/main/java/com/infoloop/tianting/service/impl/OrderServiceImpl.java
View file @
6cd094a
...
...
@@ -299,7 +299,7 @@ public class OrderServiceImpl implements OrderService {
.
menuId
(
r
.
getMenuId
())
.
pickupCode
(
r
.
getPickupCode
())
.
tableCode
(
r
.
getTableCode
())
.
roomNo
(
r
.
getRoomNo
())
.
roomNo
(
r
.
get
SyncRoomNo
().
isEmpty
()
?
r
.
getRoomNo
()
:
r
.
getSync
RoomNo
())
.
status
(
r
.
getStatus
())
.
customerNoticeJson
(
CustomerNotice
.
builder
()
.
avoids
(
r
.
getCustomerNoticeJson
().
getAvoidsList
())
...
...
@@ -372,7 +372,7 @@ public class OrderServiceImpl implements OrderService {
.
menuId
(
r
.
getMenuId
())
.
pickupCode
(
r
.
getPickupCode
())
.
tableCode
(
r
.
getTableCode
())
.
roomNo
(
r
.
getRoomNo
())
.
roomNo
(
r
.
get
SyncRoomNo
().
isEmpty
()
?
r
.
getRoomNo
()
:
r
.
getSync
RoomNo
())
.
status
(
r
.
getStatus
())
.
customerNoticeJson
(
CustomerNotice
.
builder
()
.
avoids
(
r
.
getCustomerNoticeJson
().
getAvoidsList
())
...
...
@@ -448,7 +448,8 @@ public class OrderServiceImpl implements OrderService {
.
menuId
(
r
.
getMenuId
())
.
pickupCode
(
r
.
getPickupCode
())
.
tableCode
(
r
.
getTableCode
())
.
roomNo
(
r
.
getRoomNo
())
.
roomNo
(
r
.
getSyncRoomNo
().
isEmpty
()
?
r
.
getRoomNo
()
:
r
.
getSyncRoomNo
())
.
adjustRoomNo
(!
r
.
getSyncRoomNo
().
isEmpty
())
.
status
(
r
.
getStatus
())
.
customerNoticeJson
(
CustomerNotice
.
builder
()
.
avoids
(
r
.
getCustomerNoticeJson
().
getAvoidsList
())
...
...
src/main/proto/ClientCustomerOrderService.proto
View file @
6cd094a
...
...
@@ -138,6 +138,7 @@ message SingleClientCustomerOrderRpcResponse {
bool
isRead
=
33
;
bool
isConfirm
=
34
;
bool
isAllocation
=
35
;
string
syncRoomNo
=
36
;
}
message
GetClientCustomerOrderByIdRpcRequest
{
...
...
@@ -243,6 +244,8 @@ message QueryClientCustomerOrdersByConditionRpcRequest {
bool
isConfirm
=
45
;
bool
shouldFilterIsAllocation
=
46
;
bool
isAllocation
=
47
;
bool
shouldFilterStatues
=
48
;
repeated
OrderStatusEnum
statues
=
49
;
}
message
QueryClientCustomerOrdersByConditionRpcResponse
{
...
...
@@ -370,6 +373,8 @@ message ClientCustomerOrderModification {
bool
isConfirm
=
51
;
bool
shouldUpdateIsAllocation
=
52
;
bool
isAllocation
=
53
;
bool
shouldUpdateSyncRoomNo
=
54
;
string
syncRoomNo
=
55
;
}
message
UpdateClientCustomerOrderRpcRequest
{
...
...
src/main/proto/ClientCustomerService.proto
View file @
6cd094a
...
...
@@ -40,6 +40,7 @@ service ClientCustomerServiceRpc {
rpc
GetClientCustomerHospitalRecordByCustomerId
(
GetClientCustomerHospitalRecordByCustomerIdRpcRequest
)
returns
(
GetClientCustomerHospitalRecordByCustomerIdRpcResponse
)
{}
//根据客户IDS查询住院记录
rpc
GetClientCustomerHospitalRecordsByCustomerIds
(
GetClientCustomerHospitalRecordsByCustomerIdsRpcRequest
)
returns
(
GetClientCustomerHospitalRecordsByCustomerIdsRpcResponse
)
{}
rpc
GetClientCustomerHospitalRecordsByHISCustomerIds
(
GetClientCustomerHospitalRecordsByHISCustomerIdsRpcRequest
)
returns
(
GetClientCustomerHospitalRecordsByHISCustomerIdsRpcResponse
)
{}
rpc
QueryClientCustomerHospitalRecordsByCondition
(
QueryClientCustomerHospitalRecordsByConditionRpcRequest
)
returns
(
QueryClientCustomerHospitalRecordsByConditionRpcResponse
)
{}
rpc
CreateClientCustomerHospitalRecord
(
CreateClientCustomerHospitalRecordRpcRequest
)
returns
(
CreateClientCustomerHospitalRecordRpcResponse
)
{}
rpc
BatchCreateClientCustomerHospitalRecords
(
BatchCreateClientCustomerHospitalRecordsRpcRequest
)
returns
(
BatchCreateClientCustomerHospitalRecordsRpcResponse
)
{}
...
...
@@ -385,6 +386,16 @@ message GetClientCustomerHospitalRecordsByCustomerIdsRpcResponse {
repeated
SingleClientCustomerHospitalRecordRpcResponse
responses
=
1
;
}
message
GetClientCustomerHospitalRecordsByHISCustomerIdsRpcRequest
{
repeated
string
HISCustomerIds
=
1
;
int32
enterpriseId
=
2
;
bool
includeDeleted
=
3
;
}
message
GetClientCustomerHospitalRecordsByHISCustomerIdsRpcResponse
{
repeated
SingleClientCustomerHospitalRecordRpcResponse
responses
=
1
;
}
message
QueryClientCustomerHospitalRecordsByConditionRpcRequest
{
int32
enterpriseId
=
1
;
bool
shouldFilterClientIds
=
2
;
...
...
src/main/resources/application.properties
View file @
6cd094a
...
...
@@ -58,7 +58,7 @@ grpc.meal-service.port=3017
grpc.delivery-
service.url
=
47.101.193.136
grpc.delivery-
service.port
=
3017
grpc.operator-
service.url
=
47.101.193.136
grpc.operator-
service.url
=
115.190.92.112
grpc.operator-
service.port
=
3031
grpc.woperator-
service.url
=
47.101.193.136
...
...
@@ -67,6 +67,9 @@ grpc.woperator-service.port=3028
grpc.enterprise-resource-
service.url
=
47.101.193.136
grpc.enterprise-resource-
service.port
=
3026
grpc.client-resource-
service.url
=
47.101.193.136
grpc.client-resource-
service.port
=
3019
grpc.meizhongyihe-
service.url
=
47.101.193.136
grpc.meizhongyihe-
service.port
=
3040
...
...
Please
register
or
login
to post a comment