zhuyifan

同步房间号

Showing 38 changed files with 442 additions and 244 deletions
......@@ -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);
}
}
......
......@@ -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();
......
......@@ -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";
......
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;
}
}
......
......@@ -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() {
......
......@@ -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();
}
}
......
......@@ -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);
}
}
......
......@@ -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);
}
}
......
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);
}
}
......
......@@ -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);
}
}
......
......@@ -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();
}
}
......
......@@ -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);
}
......
......@@ -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;
}
}
......
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
......
......@@ -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;
......
......@@ -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");
}
......
......@@ -5,7 +5,8 @@ import lombok.Getter;
@Getter
public enum MessageTypeEnum {
ORDER("订单类型消息");
ORDER("订单类型消息"),
CUSTOMER("客户类型消息");;
private final String description;
......
......@@ -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;
......
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;
}
}
......@@ -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;
}
......
......@@ -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();
}
}
......
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());
}
}
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();
}
}
......
......@@ -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();
}
......
......@@ -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);
......
......@@ -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());
}
}
......
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());
}
}
......
......@@ -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())
......
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().getSyncRoomNo().isEmpty() ? order.get().getRoomNo() : order.get().getSyncRoomNo())
.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.getSyncRoomNo().isEmpty() ? order.getRoomNo() : order.getSyncRoomNo())
.tableCode(order.getTableCode())
.customerNotice(CustomerNotice.builder()
.doctors(order.getCustomerNoticeJson().getDoctorsList())
......
......@@ -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())
......
......@@ -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())
......
......@@ -299,7 +299,7 @@ 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())
.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.getSyncRoomNo().isEmpty() ? r.getRoomNo() : r.getSyncRoomNo())
.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())
......
......@@ -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 {
......
......@@ -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;
......
......@@ -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
......