Showing
8 changed files
with
36 additions
and
190 deletions
| ... | @@ -76,7 +76,9 @@ CREATE TABLE `client_customer_order_details` ( | ... | @@ -76,7 +76,9 @@ CREATE TABLE `client_customer_order_details` ( |
| 76 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='项目点客户订单详情表'; | 76 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='项目点客户订单详情表'; |
| 77 | 77 | ||
| 78 | ALTER TABLE `client_customer_order_details` | 78 | ALTER TABLE `client_customer_order_details` |
| 79 | -ADD COLUMN `adjustSkuRemark` varchar(255) DEFAULT NULL COMMENT '调整配料' AFTER `price`; | 79 | +ADD COLUMN `adjustSkuRemark` varchar(255) DEFAULT NULL COMMENT '调整配料' AFTER `price`, |
| 80 | +ADD COLUMN `serveStatus` INT COMMENT '出餐状态:未出餐=1; 不出餐=2; 已出餐=3' AFTER `adjustSkuRemark`, | ||
| 81 | +DROP COLUMN `notServe`; | ||
| 80 | 82 | ||
| 81 | CREATE TABLE `client_customer_order_operation_records` ( | 83 | CREATE TABLE `client_customer_order_operation_records` ( |
| 82 | `id` INT AUTO_INCREMENT PRIMARY KEY COMMENT '订单操作记录id', | 84 | `id` INT AUTO_INCREMENT PRIMARY KEY COMMENT '订单操作记录id', | ... | ... |
| ... | @@ -113,9 +113,9 @@ public class OrderDetailDb extends Model<OrderDetailDb> implements Serializable | ... | @@ -113,9 +113,9 @@ public class OrderDetailDb extends Model<OrderDetailDb> implements Serializable |
| 113 | */ | 113 | */ |
| 114 | private Integer updateSource; | 114 | private Integer updateSource; |
| 115 | /** | 115 | /** |
| 116 | - * 不出餐: 默认出餐=0; 不出餐=1 | 116 | + * 出餐状态: 默认未出餐=1; 不出餐=2;已出餐=3 |
| 117 | */ | 117 | */ |
| 118 | - private Boolean notServe; | 118 | + private Integer serveStatus; |
| 119 | /** | 119 | /** |
| 120 | * 调整配料备注 | 120 | * 调整配料备注 |
| 121 | */ | 121 | */ | ... | ... |
| ... | @@ -58,7 +58,6 @@ import com.tianting.infoloop.service.OrderDbService; | ... | @@ -58,7 +58,6 @@ import com.tianting.infoloop.service.OrderDbService; |
| 58 | import com.tianting.infoloop.service.OrderDetailDbService; | 58 | import com.tianting.infoloop.service.OrderDetailDbService; |
| 59 | import com.tianting.infoloop.service.OrderOperationRecordDbService; | 59 | import com.tianting.infoloop.service.OrderOperationRecordDbService; |
| 60 | import com.tianting.infoloop.utils.DbToProtoUtil; | 60 | import com.tianting.infoloop.utils.DbToProtoUtil; |
| 61 | -import com.tianting.infoloop.utils.GenericBeanToProtoListConverter; | ||
| 62 | import com.tianting.infoloop.utils.ProtoBeanUtil; | 61 | import com.tianting.infoloop.utils.ProtoBeanUtil; |
| 63 | import io.grpc.Status; | 62 | import io.grpc.Status; |
| 64 | import io.grpc.stub.StreamObserver; | 63 | import io.grpc.stub.StreamObserver; | ... | ... |
| ... | @@ -12,6 +12,7 @@ import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderCreat | ... | @@ -12,6 +12,7 @@ import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderCreat |
| 12 | import com.infoloop.tianting.clientcustomerorderservice.CreateClientCustomerOrderRpcRequest; | 12 | import com.infoloop.tianting.clientcustomerorderservice.CreateClientCustomerOrderRpcRequest; |
| 13 | import com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum; | 13 | import com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum; |
| 14 | import com.infoloop.tianting.clientcustomerorderservice.PayStatusEnum; | 14 | import com.infoloop.tianting.clientcustomerorderservice.PayStatusEnum; |
| 15 | +import com.infoloop.tianting.clientcustomerorderservice.ServeStatusEnum; | ||
| 15 | import com.infoloop.tianting.clientcustomerorderservice.UpdateClientCustomerOrderRpcRequest; | 16 | import com.infoloop.tianting.clientcustomerorderservice.UpdateClientCustomerOrderRpcRequest; |
| 16 | import com.tianting.infoloop.mapper.OrderDbMapper; | 17 | import com.tianting.infoloop.mapper.OrderDbMapper; |
| 17 | import com.tianting.infoloop.model.db.OrderDb; | 18 | import com.tianting.infoloop.model.db.OrderDb; |
| ... | @@ -152,7 +153,7 @@ public class OrderDbServiceImpl extends ServiceImpl<OrderDbMapper, OrderDb> impl | ... | @@ -152,7 +153,7 @@ public class OrderDbServiceImpl extends ServiceImpl<OrderDbMapper, OrderDb> impl |
| 152 | if (detailCreation.getShouldCreateAdjustSkuRemark()) { | 153 | if (detailCreation.getShouldCreateAdjustSkuRemark()) { |
| 153 | orderDetailDb.setAdjustSkuRemark(detailCreation.getAdjustSkuRemark()); | 154 | orderDetailDb.setAdjustSkuRemark(detailCreation.getAdjustSkuRemark()); |
| 154 | } | 155 | } |
| 155 | - orderDetailDb.setNotServe(false); | 156 | + orderDetailDb.setServeStatus(ServeStatusEnum.SERVE_NOT_START_VALUE); |
| 156 | if (detailCreation.getShouldCreateMealDetailJson()) { | 157 | if (detailCreation.getShouldCreateMealDetailJson()) { |
| 157 | orderDetailDb.setMealDetailJson(objectMapper.valueToTree(MealDetailJson.builder() | 158 | orderDetailDb.setMealDetailJson(objectMapper.valueToTree(MealDetailJson.builder() |
| 158 | .allergies(detailCreation.getMealDetailJson().getAllergiesList()) | 159 | .allergies(detailCreation.getMealDetailJson().getAllergiesList()) |
| ... | @@ -374,7 +375,7 @@ public class OrderDbServiceImpl extends ServiceImpl<OrderDbMapper, OrderDb> impl | ... | @@ -374,7 +375,7 @@ public class OrderDbServiceImpl extends ServiceImpl<OrderDbMapper, OrderDb> impl |
| 374 | if (detailCreation.getShouldCreateAdjustSkuRemark()) { | 375 | if (detailCreation.getShouldCreateAdjustSkuRemark()) { |
| 375 | orderDetailDb.setAdjustSkuRemark(detailCreation.getAdjustSkuRemark()); | 376 | orderDetailDb.setAdjustSkuRemark(detailCreation.getAdjustSkuRemark()); |
| 376 | } | 377 | } |
| 377 | - orderDetailDb.setNotServe(false); | 378 | + orderDetailDb.setServeStatus(ServeStatusEnum.SERVE_NOT_START_VALUE); |
| 378 | if (detailCreation.getShouldCreateMealDetailJson()) { | 379 | if (detailCreation.getShouldCreateMealDetailJson()) { |
| 379 | orderDetailDb.setMealDetailJson(objectMapper.valueToTree(MealDetailJson.builder() | 380 | orderDetailDb.setMealDetailJson(objectMapper.valueToTree(MealDetailJson.builder() |
| 380 | .allergies(detailCreation.getMealDetailJson().getAllergiesList()) | 381 | .allergies(detailCreation.getMealDetailJson().getAllergiesList()) | ... | ... |
| ... | @@ -12,6 +12,7 @@ import com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustome | ... | @@ -12,6 +12,7 @@ import com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustome |
| 12 | import com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrderDetailsRpcRequest; | 12 | import com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrderDetailsRpcRequest; |
| 13 | import com.infoloop.tianting.clientcustomerorderservice.CreateClientCustomerOrderDetailRpcRequest; | 13 | import com.infoloop.tianting.clientcustomerorderservice.CreateClientCustomerOrderDetailRpcRequest; |
| 14 | import com.infoloop.tianting.clientcustomerorderservice.GetClientCustomerOrderDetailsByOrderIdsRpcRequest; | 14 | import com.infoloop.tianting.clientcustomerorderservice.GetClientCustomerOrderDetailsByOrderIdsRpcRequest; |
| 15 | +import com.infoloop.tianting.clientcustomerorderservice.ServeStatusEnum; | ||
| 15 | import com.infoloop.tianting.clientcustomerorderservice.UpdateClientCustomerOrderDetailRpcRequest; | 16 | import com.infoloop.tianting.clientcustomerorderservice.UpdateClientCustomerOrderDetailRpcRequest; |
| 16 | import com.tianting.infoloop.mapper.OrderDbMapper; | 17 | import com.tianting.infoloop.mapper.OrderDbMapper; |
| 17 | import com.tianting.infoloop.mapper.OrderDetailMapper; | 18 | import com.tianting.infoloop.mapper.OrderDetailMapper; |
| ... | @@ -66,7 +67,7 @@ public class OrderDetailDbServiceImpl extends ServiceImpl<OrderDetailMapper, Ord | ... | @@ -66,7 +67,7 @@ public class OrderDetailDbServiceImpl extends ServiceImpl<OrderDetailMapper, Ord |
| 66 | if (createOrderDetailRequest.getCreation().getShouldCreateAdjustSkuRemark()) { | 67 | if (createOrderDetailRequest.getCreation().getShouldCreateAdjustSkuRemark()) { |
| 67 | orderDetailDb.setAdjustSkuRemark(createOrderDetailRequest.getCreation().getAdjustSkuRemark()); | 68 | orderDetailDb.setAdjustSkuRemark(createOrderDetailRequest.getCreation().getAdjustSkuRemark()); |
| 68 | } | 69 | } |
| 69 | - orderDetailDb.setNotServe(false); | 70 | + orderDetailDb.setServeStatus(ServeStatusEnum.SERVE_NOT_START_VALUE); |
| 70 | if (createOrderDetailRequest.getCreation().getShouldCreateMealDetailJson()) { | 71 | if (createOrderDetailRequest.getCreation().getShouldCreateMealDetailJson()) { |
| 71 | orderDetailDb.setMealDetailJson(objectMapper.valueToTree(MealDetailJson.builder() | 72 | orderDetailDb.setMealDetailJson(objectMapper.valueToTree(MealDetailJson.builder() |
| 72 | .allergies(createOrderDetailRequest.getCreation().getMealDetailJson().getAllergiesList()) | 73 | .allergies(createOrderDetailRequest.getCreation().getMealDetailJson().getAllergiesList()) |
| ... | @@ -106,7 +107,7 @@ public class OrderDetailDbServiceImpl extends ServiceImpl<OrderDetailMapper, Ord | ... | @@ -106,7 +107,7 @@ public class OrderDetailDbServiceImpl extends ServiceImpl<OrderDetailMapper, Ord |
| 106 | orderDetailDb.setCategoryId(creation.getCategoryId()); | 107 | orderDetailDb.setCategoryId(creation.getCategoryId()); |
| 107 | orderDetailDb.setSkuId(creation.getSkuId()); | 108 | orderDetailDb.setSkuId(creation.getSkuId()); |
| 108 | orderDetailDb.setIsDeleted(false); | 109 | orderDetailDb.setIsDeleted(false); |
| 109 | - orderDetailDb.setNotServe(false); | 110 | + orderDetailDb.setServeStatus(ServeStatusEnum.SERVE_NOT_START_VALUE); |
| 110 | orderDetailDb.setEnterpriseId(batchCreateOrderDetailsRequest.getEnterpriseId()); | 111 | orderDetailDb.setEnterpriseId(batchCreateOrderDetailsRequest.getEnterpriseId()); |
| 111 | if (creation.getShouldCreateOrderId()) { | 112 | if (creation.getShouldCreateOrderId()) { |
| 112 | orderDetailDb.setOrderId(creation.getOrderId()); | 113 | orderDetailDb.setOrderId(creation.getOrderId()); |
| ... | @@ -173,8 +174,8 @@ public class OrderDetailDbServiceImpl extends ServiceImpl<OrderDetailMapper, Ord | ... | @@ -173,8 +174,8 @@ public class OrderDetailDbServiceImpl extends ServiceImpl<OrderDetailMapper, Ord |
| 173 | if (updateOrderDetailRequest.getModification().getShouldUpdateAdjustSkuRemark()) { | 174 | if (updateOrderDetailRequest.getModification().getShouldUpdateAdjustSkuRemark()) { |
| 174 | orderDetailDb.setAdjustSkuRemark(updateOrderDetailRequest.getModification().getAdjustSkuRemark()); | 175 | orderDetailDb.setAdjustSkuRemark(updateOrderDetailRequest.getModification().getAdjustSkuRemark()); |
| 175 | } | 176 | } |
| 176 | - if (updateOrderDetailRequest.getModification().getShouldUpdateNotServe()) { | 177 | + if (updateOrderDetailRequest.getModification().getShouldUpdateServeStatus()) { |
| 177 | - orderDetailDb.setNotServe(updateOrderDetailRequest.getModification().getNotServe()); | 178 | + orderDetailDb.setServeStatus(updateOrderDetailRequest.getModification().getServeStatusValue()); |
| 178 | } | 179 | } |
| 179 | if (updateOrderDetailRequest.getModification().getShouldUpdateMealDetailJson()) { | 180 | if (updateOrderDetailRequest.getModification().getShouldUpdateMealDetailJson()) { |
| 180 | ObjectMapper objectMapper = new ObjectMapper(); | 181 | ObjectMapper objectMapper = new ObjectMapper(); |
| ... | @@ -225,8 +226,8 @@ public class OrderDetailDbServiceImpl extends ServiceImpl<OrderDetailMapper, Ord | ... | @@ -225,8 +226,8 @@ public class OrderDetailDbServiceImpl extends ServiceImpl<OrderDetailMapper, Ord |
| 225 | if (modification.getShouldUpdateAdjustSkuRemark()) { | 226 | if (modification.getShouldUpdateAdjustSkuRemark()) { |
| 226 | orderDetailDb.setAdjustSkuRemark(modification.getAdjustSkuRemark()); | 227 | orderDetailDb.setAdjustSkuRemark(modification.getAdjustSkuRemark()); |
| 227 | } | 228 | } |
| 228 | - if (modification.getShouldUpdateNotServe()) { | 229 | + if (modification.getShouldUpdateServeStatus()) { |
| 229 | - orderDetailDb.setNotServe(modification.getNotServe()); | 230 | + orderDetailDb.setServeStatus(modification.getServeStatusValue()); |
| 230 | } | 231 | } |
| 231 | if (modification.getShouldUpdateMealDetailJson()) { | 232 | if (modification.getShouldUpdateMealDetailJson()) { |
| 232 | ObjectMapper objectMapper = new ObjectMapper(); | 233 | ObjectMapper objectMapper = new ObjectMapper(); | ... | ... |
| ... | @@ -10,6 +10,7 @@ import com.infoloop.tianting.clientcustomerorderservice.OrderSourceEnum; | ... | @@ -10,6 +10,7 @@ import com.infoloop.tianting.clientcustomerorderservice.OrderSourceEnum; |
| 10 | import com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum; | 10 | import com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum; |
| 11 | import com.infoloop.tianting.clientcustomerorderservice.OrderTypeEnum; | 11 | import com.infoloop.tianting.clientcustomerorderservice.OrderTypeEnum; |
| 12 | import com.infoloop.tianting.clientcustomerorderservice.PayStatusEnum; | 12 | import com.infoloop.tianting.clientcustomerorderservice.PayStatusEnum; |
| 13 | +import com.infoloop.tianting.clientcustomerorderservice.ServeStatusEnum; | ||
| 13 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderDetailRpcResponse; | 14 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderDetailRpcResponse; |
| 14 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse; | 15 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse; |
| 15 | import com.tianting.infoloop.model.db.OrderDb; | 16 | import com.tianting.infoloop.model.db.OrderDb; |
| ... | @@ -202,9 +203,14 @@ public class DbToProtoUtil { | ... | @@ -202,9 +203,14 @@ public class DbToProtoUtil { |
| 202 | .setUpdatedAt(orderDetailDb.getUpdatedAt().toEpochSecond(ZoneOffset.UTC) * 1000) | 203 | .setUpdatedAt(orderDetailDb.getUpdatedAt().toEpochSecond(ZoneOffset.UTC) * 1000) |
| 203 | .setUpdateSource(OrderSourceEnum.forNumber(orderDetailDb.getUpdateSource())) | 204 | .setUpdateSource(OrderSourceEnum.forNumber(orderDetailDb.getUpdateSource())) |
| 204 | .setIsDeleted(orderDetailDb.getIsDeleted()) | 205 | .setIsDeleted(orderDetailDb.getIsDeleted()) |
| 205 | - .setNotServe(orderDetailDb.getNotServe()) | ||
| 206 | .setEnterpriseId(orderDetailDb.getEnterpriseId()); | 206 | .setEnterpriseId(orderDetailDb.getEnterpriseId()); |
| 207 | 207 | ||
| 208 | + if (orderDetailDb.getServeStatus() != null) { | ||
| 209 | + protoBuilder.setServeStatus(ServeStatusEnum.forNumber(orderDetailDb.getServeStatus())); | ||
| 210 | + } else { | ||
| 211 | + protoBuilder.setServeStatus(ServeStatusEnum.SERVE_NOT_START); | ||
| 212 | + } | ||
| 213 | + | ||
| 208 | // 处理嵌套的MealDetail字段 | 214 | // 处理嵌套的MealDetail字段 |
| 209 | if (orderDetailDb.getMealDetailJson()!= null) { | 215 | if (orderDetailDb.getMealDetailJson()!= null) { |
| 210 | // Constructor<MealDetail> mealDetailConstructor = | 216 | // Constructor<MealDetail> mealDetailConstructor = |
| ... | @@ -258,17 +264,17 @@ public class DbToProtoUtil { | ... | @@ -258,17 +264,17 @@ public class DbToProtoUtil { |
| 258 | 264 | ||
| 259 | JsonNode fatNode = orderDetailDb.getMealDetailJson().get("fat"); | 265 | JsonNode fatNode = orderDetailDb.getMealDetailJson().get("fat"); |
| 260 | if (fatNode!= null && fatNode.isTextual()) { | 266 | if (fatNode!= null && fatNode.isTextual()) { |
| 261 | - mealDetailProto.setFat(energyNode.textValue()); | 267 | + mealDetailProto.setFat(fatNode.textValue()); |
| 262 | } | 268 | } |
| 263 | 269 | ||
| 264 | JsonNode proteinNode = orderDetailDb.getMealDetailJson().get("protein"); | 270 | JsonNode proteinNode = orderDetailDb.getMealDetailJson().get("protein"); |
| 265 | if (proteinNode!= null && proteinNode.isTextual()) { | 271 | if (proteinNode!= null && proteinNode.isTextual()) { |
| 266 | - mealDetailProto.setProtein(energyNode.textValue()); | 272 | + mealDetailProto.setProtein(proteinNode.textValue()); |
| 267 | } | 273 | } |
| 268 | 274 | ||
| 269 | JsonNode carbohydrateNode = orderDetailDb.getMealDetailJson().get("carbohydrate"); | 275 | JsonNode carbohydrateNode = orderDetailDb.getMealDetailJson().get("carbohydrate"); |
| 270 | if (carbohydrateNode!= null && carbohydrateNode.isTextual()) { | 276 | if (carbohydrateNode!= null && carbohydrateNode.isTextual()) { |
| 271 | - mealDetailProto.setCarbohydrate(energyNode.textValue()); | 277 | + mealDetailProto.setCarbohydrate(carbohydrateNode.textValue()); |
| 272 | } | 278 | } |
| 273 | 279 | ||
| 274 | JsonNode allergiesNode = orderDetailDb.getMealDetailJson().get("allergies"); | 280 | JsonNode allergiesNode = orderDetailDb.getMealDetailJson().get("allergies"); | ... | ... |
| 1 | -package com.tianting.infoloop.utils; | ||
| 2 | - | ||
| 3 | -import com.fasterxml.jackson.databind.JsonNode; | ||
| 4 | -import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 5 | -import com.google.protobuf.Message; | ||
| 6 | -import com.google.protobuf.util.JsonFormat; | ||
| 7 | -import java.lang.reflect.Constructor; | ||
| 8 | -import java.lang.reflect.Field; | ||
| 9 | -import java.time.Instant; | ||
| 10 | -import java.time.LocalDateTime; | ||
| 11 | -import java.time.ZoneOffset; | ||
| 12 | -import java.util.ArrayList; | ||
| 13 | -import java.util.Iterator; | ||
| 14 | -import java.util.List; | ||
| 15 | -import java.util.Map; | ||
| 16 | - | ||
| 17 | -public class GenericBeanToProtoListConverter { | ||
| 18 | - | ||
| 19 | - // 将Java Bean列表转换为对应的ProtoBuf消息列表 | ||
| 20 | - public static <M, T extends Message> List<T> beanListToProtoList(List<M> beanSourceList, Class<T> protoBean) { | ||
| 21 | - List<T> resultList = new ArrayList<>(); | ||
| 22 | - | ||
| 23 | - try { | ||
| 24 | - for (M bean : beanSourceList) { | ||
| 25 | - // 创建ProtoBuf消息实例 | ||
| 26 | - Constructor<T> declaredConstructor; | ||
| 27 | - try { | ||
| 28 | - declaredConstructor = protoBean.getDeclaredConstructor(); | ||
| 29 | - declaredConstructor.setAccessible(true); | ||
| 30 | - T instance = declaredConstructor.newInstance(); | ||
| 31 | - | ||
| 32 | - // 将Java Bean的各个字段值设置到ProtoBuf消息实例中 | ||
| 33 | - setProtoFieldsFromBean(bean, instance, true); | ||
| 34 | - | ||
| 35 | - resultList.add(instance); | ||
| 36 | - } catch (NoSuchMethodException e) { | ||
| 37 | - // 如果没有无参构造函数,尝试查找其他构造函数并传入合适参数(这里假设可以传入空参数列表创建实例,实际可能需根据具体情况调整) | ||
| 38 | - Constructor<?>[] constructors = protoBean.getConstructors(); | ||
| 39 | - if (constructors.length > 0) { | ||
| 40 | - declaredConstructor = (Constructor<T>) constructors[0]; | ||
| 41 | - declaredConstructor.setAccessible(true); | ||
| 42 | - T instance = declaredConstructor.newInstance(); | ||
| 43 | - | ||
| 44 | - // 将Java Bean的各个字段值设置到ProtoBuf消息实例中 | ||
| 45 | - setProtoFieldsFromBean(bean, instance, true); | ||
| 46 | - | ||
| 47 | - resultList.add(instance); | ||
| 48 | - } else { | ||
| 49 | - throw new IllegalArgumentException("ProtoBuf消息类型 " + protoBean.getName() + " 没有可用的构造函数来创建实例", e); | ||
| 50 | - } | ||
| 51 | - } | ||
| 52 | - } | ||
| 53 | - } catch (Exception e) { | ||
| 54 | - e.printStackTrace(); | ||
| 55 | - // 根据具体需求,可在这里进行更详细的错误处理,比如抛出特定的转换失败异常给调用者等 | ||
| 56 | - throw new RuntimeException("Java Bean列表转换为ProtoBuf消息列表失败", e); | ||
| 57 | - } | ||
| 58 | - | ||
| 59 | - return resultList; | ||
| 60 | - } | ||
| 61 | - | ||
| 62 | - // 将Java Bean的各个字段值设置到ProtoBuf消息实例中 | ||
| 63 | - private static <M, T extends Message> void setProtoFieldsFromBean(M bean, T protoInstance, boolean ignoreUnknownFields) throws Exception { | ||
| 64 | - // 获取Java Bean的所有字段 | ||
| 65 | - Field[] beanFields = bean.getClass().getDeclaredFields(); | ||
| 66 | - for (Field beanField : beanFields) { | ||
| 67 | - beanField.setAccessible(true); | ||
| 68 | - | ||
| 69 | - // 获取ProtoBuf消息实例中对应的字段 | ||
| 70 | - Field protoField; | ||
| 71 | - try { | ||
| 72 | - protoField = protoInstance.getClass().getDeclaredField(beanField.getName()); | ||
| 73 | - protoField.setAccessible(true); | ||
| 74 | - } catch (NoSuchFieldException e) { | ||
| 75 | - if (ignoreUnknownFields) { | ||
| 76 | - continue; | ||
| 77 | - } else { | ||
| 78 | - throw e; | ||
| 79 | - } | ||
| 80 | - } | ||
| 81 | - | ||
| 82 | - // 获取Java Bean字段的值 | ||
| 83 | - Object beanFieldValue = beanField.get(bean); | ||
| 84 | - | ||
| 85 | - if (beanFieldValue!= null) { | ||
| 86 | - if (beanFieldValue instanceof JsonNode) { | ||
| 87 | - // 处理JsonNode类型的字段 | ||
| 88 | - JsonNode jsonNodeValue = (JsonNode) beanFieldValue; | ||
| 89 | - | ||
| 90 | - // 创建对应的嵌套ProtoBuf消息实例(假设是嵌套消息类型,这里以通用的处理方式为例) | ||
| 91 | - Constructor<?> nestedProtoConstructor = protoField.getType().getDeclaredConstructor(); | ||
| 92 | - nestedProtoConstructor.setAccessible(true); | ||
| 93 | - Object nestedProtoInstance = nestedProtoConstructor.newInstance(); | ||
| 94 | - | ||
| 95 | - // 设置嵌套ProtoBuf消息实例的字段值(这里假设嵌套消息类型有类似的处理逻辑,具体根据实际情况而定) | ||
| 96 | - setProtoFieldsFromBean(jsonNodeValue, nestedProtoInstance, ignoreUnknownFields); | ||
| 97 | - | ||
| 98 | - // 将设置好的嵌套ProtoBuf消息实例设置到ProtoBuf消息实例的对应字段中 | ||
| 99 | - protoField.set(protoInstance, nestedProtoInstance); | ||
| 100 | - } else if (beanFieldValue instanceof LocalDateTime) { | ||
| 101 | - // 处理LocalDateTime类型的字段,将其转换为时间戳(毫秒)后设置到ProtoBuf消息实例中 | ||
| 102 | - LocalDateTime localDateTimeValue = (LocalDateTime) beanFieldValue; | ||
| 103 | - long timestamp = localDateTimeValue.toInstant(ZoneOffset.UTC).toEpochMilli(); | ||
| 104 | - protoField.set(protoInstance, timestamp); | ||
| 105 | - } else if (beanFieldValue instanceof Integer) { | ||
| 106 | - // 处理Integer类型字段,直接设置到ProtoBuf消息实例对应字段 | ||
| 107 | - protoField.set(protoInstance, (Integer) beanFieldValue); | ||
| 108 | - } else if (beanFieldValue instanceof String) { | ||
| 109 | - // 处理String类型字段,直接设置到ProtoBuf消息实例对应字段 | ||
| 110 | - protoField.set(protoInstance, (String) beanFieldValue); | ||
| 111 | - } else if (beanFieldValue instanceof Boolean) { | ||
| 112 | - // 处理Boolean类型字段,直接设置到ProtoBuf消息实例对应字段 | ||
| 113 | - protoField.set(protoInstance, (Boolean) beanFieldValue); | ||
| 114 | - } else if (beanFieldValue instanceof Long) { | ||
| 115 | - // 处理Long类型字段,直接设置到ProtoBuf消息实例对应字段 | ||
| 116 | - protoField.set(protoInstance, (Long) beanFieldValue); | ||
| 117 | - } else { | ||
| 118 | - // 对于其他未明确处理的类型,尝试通过其toString方法转换为字符串后设置(可能需要根据具体类型进一步优化) | ||
| 119 | - protoField.set(protoInstance, beanFieldValue.toString()); | ||
| 120 | - } | ||
| 121 | - } else { | ||
| 122 | - // 如果Java Bean字段的值为null,将ProtoBuf消息实例的对应字段也设置为null | ||
| 123 | - protoField.set(protoInstance, null); | ||
| 124 | - } | ||
| 125 | - } | ||
| 126 | - } | ||
| 127 | - | ||
| 128 | - // 将JsonNode的值设置到对应的ProtoBuf消息实例(这里假设是嵌套消息类型,以通用处理方式为例) | ||
| 129 | - private static void setProtoFieldsFromBean(JsonNode jsonNode, Object protoInstance, boolean ignoreUnknownFields) throws Exception { | ||
| 130 | - // 获取JsonNode的所有字段 | ||
| 131 | - Iterator<Map.Entry<String, JsonNode>> jsonNodeFields = jsonNode.fields(); | ||
| 132 | - while (jsonNodeFields.hasNext()) { | ||
| 133 | - Map.Entry<String, JsonNode> entry = jsonNodeFields.next(); | ||
| 134 | - String fieldName = entry.getKey(); | ||
| 135 | - JsonNode fieldValue = entry.getValue(); | ||
| 136 | - | ||
| 137 | - // 获取ProtoBuf消息实例中对应的字段 | ||
| 138 | - Field protoField; | ||
| 139 | - try { | ||
| 140 | - protoField = protoInstance.getClass().getDeclaredField(fieldName); | ||
| 141 | - protoField.setAccessible(true); | ||
| 142 | - } catch (NoSuchFieldException e) { | ||
| 143 | - if (ignoreUnknownFields) { | ||
| 144 | - continue; | ||
| 145 | - } else { | ||
| 146 | - throw e; | ||
| 147 | - } | ||
| 148 | - } | ||
| 149 | - | ||
| 150 | - if (fieldValue!= null) { | ||
| 151 | - if (fieldValue instanceof JsonNode) { | ||
| 152 | - // 递归处理嵌套的JsonNode类型的字段 | ||
| 153 | - Constructor<?> nestedProtoConstructor = protoField.getType().getDeclaredConstructor(); | ||
| 154 | - nestedProtoConstructor.setAccessible(true); | ||
| 155 | - Object nestedProtoInstance = nestedProtoInstance = nestedProtoConstructor.newInstance(); | ||
| 156 | - | ||
| 157 | - setProtoFieldsFromBean((JsonNode) fieldValue, nestedProtoInstance, ignoreUnknownFields); | ||
| 158 | - | ||
| 159 | - protoField.set(protoInstance, nestedProtoInstance); | ||
| 160 | - } else { | ||
| 161 | - // 将非JsonNode类型的值设置到ProtoBuf消息实例的对应字段中 | ||
| 162 | - protoField.set(protoInstance, fieldValue.asText()); | ||
| 163 | - } | ||
| 164 | - } else { | ||
| 165 | - // 如果JsonNode字段的值为null,将ProtoBuf消息实例的对应字段也设置为null | ||
| 166 | - protoField.set(protoInstance, null); | ||
| 167 | - } | ||
| 168 | - } | ||
| 169 | - } | ||
| 170 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| ... | @@ -72,6 +72,13 @@ enum CloseTimeType { | ... | @@ -72,6 +72,13 @@ enum CloseTimeType { |
| 72 | RESERVATION = 1; | 72 | RESERVATION = 1; |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | +enum ServeStatusEnum { | ||
| 76 | + UNKNOWN_SERVE_STATUS = 0; | ||
| 77 | + SERVE_NOT_START = 1; | ||
| 78 | + SERVE_REJECT = 2; | ||
| 79 | + SERVE_FINISHED = 3; | ||
| 80 | +} | ||
| 81 | + | ||
| 75 | message CustomerNotice { | 82 | message CustomerNotice { |
| 76 | repeated string avoids = 1; | 83 | repeated string avoids = 1; |
| 77 | repeated string doctors = 2; | 84 | repeated string doctors = 2; |
| ... | @@ -403,7 +410,7 @@ message SingleClientCustomerOrderDetailRpcResponse { | ... | @@ -403,7 +410,7 @@ message SingleClientCustomerOrderDetailRpcResponse { |
| 403 | int64 updatedAt = 16; | 410 | int64 updatedAt = 16; |
| 404 | OrderSourceEnum updateSource = 17; | 411 | OrderSourceEnum updateSource = 17; |
| 405 | bool isDeleted = 18; | 412 | bool isDeleted = 18; |
| 406 | - bool notServe = 19; | 413 | + ServeStatusEnum serveStatus = 19; |
| 407 | int32 enterpriseId = 20; | 414 | int32 enterpriseId = 20; |
| 408 | } | 415 | } |
| 409 | 416 | ||
| ... | @@ -450,7 +457,7 @@ message ClientCustomerOrderDetailCreation{ | ... | @@ -450,7 +457,7 @@ message ClientCustomerOrderDetailCreation{ |
| 450 | int32 price = 13; | 457 | int32 price = 13; |
| 451 | bool shouldCreateAdjustSkuRemark = 14; | 458 | bool shouldCreateAdjustSkuRemark = 14; |
| 452 | string adjustSkuRemark = 15; | 459 | string adjustSkuRemark = 15; |
| 453 | - bool notServe = 16; | 460 | + ServeStatusEnum serveStatus= 16; |
| 454 | } | 461 | } |
| 455 | 462 | ||
| 456 | message CreateClientCustomerOrderDetailRpcRequest { | 463 | message CreateClientCustomerOrderDetailRpcRequest { |
| ... | @@ -497,8 +504,8 @@ message ClientCustomerOrderDetailModification { | ... | @@ -497,8 +504,8 @@ message ClientCustomerOrderDetailModification { |
| 497 | int32 price = 17; | 504 | int32 price = 17; |
| 498 | bool shouldUpdateAdjustSkuRemark = 18; | 505 | bool shouldUpdateAdjustSkuRemark = 18; |
| 499 | string adjustSkuRemark = 19; | 506 | string adjustSkuRemark = 19; |
| 500 | - bool shouldUpdateNotServe = 20; | 507 | + bool shouldUpdateServeStatus = 20; |
| 501 | - bool notServe = 21; | 508 | + ServeStatusEnum serveStatus = 21; |
| 502 | } | 509 | } |
| 503 | 510 | ||
| 504 | message UpdateClientCustomerOrderDetailRpcRequest { | 511 | message UpdateClientCustomerOrderDetailRpcRequest { | ... | ... |
-
Please register or login to post a comment