From 3cd7e2161853efda3a82456bd74fb1b029dcdcd7 Mon Sep 17 00:00:00 2001 From: Administrator Date: Sun, 29 Dec 2024 16:07:16 +0800 Subject: [PATCH] add code review new filelanzhouhailiang_one-master_merge-zhangzq-1735459636432-nREh.md --- ...master_merge-zhangzq-1735459636432-nREh.md | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 2024-12-29/lanzhouhailiang_one-master_merge-zhangzq-1735459636432-nREh.md diff --git a/2024-12-29/lanzhouhailiang_one-master_merge-zhangzq-1735459636432-nREh.md b/2024-12-29/lanzhouhailiang_one-master_merge-zhangzq-1735459636432-nREh.md new file mode 100644 index 0000000..8356268 --- /dev/null +++ b/2024-12-29/lanzhouhailiang_one-master_merge-zhangzq-1735459636432-nREh.md @@ -0,0 +1,49 @@ +根据提供的`git diff`记录,以下是针对两个Java类`InBoxManageServiceImpl`和`InVehicleManageServiceImpl`的代码评审: + +### InBoxManageServiceImpl.java +```java +diff --git a/lms/nladmin-system/src/main/java/org/nl/b_lms/storage_manage/ios/service/iostorInv/util/impl/InBoxManageServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/b_lms/storage_manage/ios/service/iostorInv/util/impl/InBoxManageServiceImpl.java +index f2df03e..b4dc820 100644 +--- a/lms/nladmin-system/src/main/java/org/nl/b_lms/storage_manage/ios/service/iostorInv/util/impl/InBoxManageServiceImpl.java ++++ b/lms/nladmin-system/src/main/java/org/nl/b_lms/storage_manage/ios/service/iostorInv/util/impl/InBoxManageServiceImpl.java +@@ -102,7 +102,7 @@ + // Review: + // The original code used 'box_arr' to refer to the "box_no" in the query, but it is not defined in the snippet. + // It is assumed that 'box_arr' should be replaced with 'whereJson.getString("box_no")' to avoid potential NPE. + WQLObject attrTab = WQLObject.getWQLObject("st_ivt_structattr"); +- String box_arr = whereJson.getString("box_no"); ++ String boxNo = whereJson.getString("box_no"); + int count = ischBaseTaskService.count(new QueryWrapper() +- .eq("start_device_code", whereJson.getString("device_code")) ++ .eq("point_code1", whereJson.getString("device_code")) + .eq("vehicle_code", boxNo) // Assuming boxNo is the correct variable to use here + .eq("task_type", "010702") + .lt("task_status", TaskStatusEnum.FINISHED.getCode())); +``` + +**Review Comments:** +1. **Variable Naming:** The variable `box_arr` is not defined in the snippet provided. It should be replaced with `whereJson.getString("box_no")` to avoid a possible `NullPointerException`. +2. **Code Clarity:** It would be clearer to define `whereJson.getString("box_no")` as a variable, such as `boxNo`, and use that variable throughout the code. + +### InVehicleManageServiceImpl.java +```java +diff --git a/lms/nladmin-system/src/main/java/org/nl/b_lms/storage_manage/ios/service/iostorInv/util/impl/InVehicleManageServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/b_lms/storage_manage/ios/service/iostorInv/util/impl/InVehicleManageServiceImpl.java +index 83c47cd..7c69b2b 100644 +--- a/lms/nladmin-system/src/main/java/org/nl/b_lms/storage_manage/ios/service/iostorInv/util/impl/InVehicleManageServiceImpl.java ++++ b/lms/nladmin-system/src/main/java/org/nl/b_lms/storage_manage/ios/service/iostorInv/util/impl/InVehicleManageServiceImpl.java +index 83c47cd..7c69b2b 100644 +@@ -71,7 +71,7 @@ + // Review: + // Similar to the previous class, the original code used 'vehicle_code' directly in the query, which could be a potential NPE. + // It is assumed that the correct variable should be used to avoid a potential NullPointerException. + int count = ischBaseTaskService.count(new QueryWrapper() +- .eq("start_device_code", whereJson.getString("device_code")) ++ .eq("point_code1", whereJson.getString("device_code")) + .eq("vehicle_code", whereJson.getString("vehicle_code")) + .eq("task_type", "010705") + .lt("task_status", TaskStatusEnum.EXECUTING.getCode())); +``` + +**Review Comments:** +1. **Variable Naming:** The `vehicle_code` is used directly in the query without checking if it is null or not. It should be wrapped in a null check or replaced with a defined variable that has been validated for null. +2. **Code Clarity:** Similar to the `InBoxManageServiceImpl`, it would be clearer to define `whereJson.getString("vehicle_code")` as a variable and use that variable in the query. \ No newline at end of file