Browse Source

feat(hikiot): 支持设置人员权限生效时间段

- 在 addUser 方法中新增 frameTimeStr 参数用于指定生效时间段- 解析 frameTimeStr 格式 "HH:mm:ss-HH:mm:ss" 并应用于权限起止时间
- 调整 OrderServiceImpl 中对 addUser 方法的调用以传递 frameTimeStr 参数
- 对于无需自定义时间段的场景,允许传入 null 值保持原有逻辑
SheepHy 1 month ago
parent
commit
f88040981f

+ 4 - 4
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/OrderServiceImpl.java

@@ -1163,7 +1163,7 @@ public class OrderServiceImpl extends ServiceImpl<AppOrderMapper, AppOrder> impl
                                 JsonObject addUserJson = JsonParser.parseString(addUser(new DateTime(proInfo2.getExpireTime()),
                                         appDevice.getDeviceSerial(),
                                         appOrderProInfo.getUserName(),
-                                        familyMembers.getId(), new DateTime(proInfo1.getExpireTime()))).getAsJsonObject();
+                                        familyMembers.getId(), new DateTime(proInfo1.getExpireTime()), appOrderProInfo.getFrameTimeStr())).getAsJsonObject();
                                 JsonObject addFaceJson = JsonParser.parseString(addFace(appDevice.getDeviceSerial(), familyMembers.getId(),
                                         familyMembers.getRealNameImg())).getAsJsonObject();
                                 if (addUserJson.get("code").getAsInt() != 0 && addFaceJson.get("code").getAsInt() != 0) {
@@ -1173,7 +1173,7 @@ public class OrderServiceImpl extends ServiceImpl<AppOrderMapper, AppOrder> impl
                                 JsonObject addUserJson = JsonParser.parseString(addUser(new Date(),
                                         appDevice.getDeviceSerial(),
                                         appOrderProInfo.getUserName(),
-                                        familyMembers.getId(), new DateTime(appOrderProInfo.getExpireTime()))).getAsJsonObject();
+                                        familyMembers.getId(), new DateTime(appOrderProInfo.getExpireTime()), appOrderProInfo.getFrameTimeStr())).getAsJsonObject();
                                 JsonObject addFaceJson = JsonParser.parseString(addFace(appDevice.getDeviceSerial(), familyMembers.getId(),
                                         familyMembers.getRealNameImg())).getAsJsonObject();
                                 if (addUserJson.get("code").getAsInt() != 0 && addFaceJson.get("code").getAsInt() != 0) {
@@ -1260,7 +1260,7 @@ public class OrderServiceImpl extends ServiceImpl<AppOrderMapper, AppOrder> impl
                         String addUser = addUser(new DateTime(proInfo2.getExpireTime()),
                                 appDevice.getDeviceSerial(),
                                 appOrderProInfo.getUserName(),
-                                familyMembers.getId(), new DateTime(proInfo1.getExpireTime()));
+                                familyMembers.getId(), new DateTime(proInfo1.getExpireTime()), null);
                         String addFace = addFace(appDevice.getDeviceSerial(), familyMembers.getId(),
                                 familyMembers.getRealNameImg());
                         JsonObject addUserJson = JsonParser.parseString(addUser).getAsJsonObject();
@@ -1271,7 +1271,7 @@ public class OrderServiceImpl extends ServiceImpl<AppOrderMapper, AppOrder> impl
                         String addUser = addUser(appSitePriceRulesMapper.selectById(appOrderProInfo.getProductId()).getDateOfSale(),
                                 appDevice.getDeviceSerial(),
                                 appOrderProInfo.getUserName(),
-                                familyMembers.getId(), null);
+                                familyMembers.getId(), null,null);
                         String addFace = addFace(appDevice.getDeviceSerial(), familyMembers.getId(),
                                 familyMembers.getRealNameImg());
                         JsonObject addUserJson = JsonParser.parseString(addUser).getAsJsonObject();

+ 12 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/hikiot/HikiotTool.java

@@ -199,7 +199,7 @@ public class HikiotTool {
      * @Description 新增/修改人员
      * @Date 9:35 2025/8/15
      **/
-    public static String addUser(Date inputDate,String deviceSerial,String name,String employeeNo,Date endDate){
+    public static String addUser(Date inputDate,String deviceSerial,String name,String employeeNo,Date endDate, String frameTimeStr){
         LocalDateTime now = inputDate.toInstant()
                 .atZone(ZoneId.systemDefault())
                 .toLocalDateTime();
@@ -212,6 +212,17 @@ public class HikiotTool {
                     .plusDays(1);
             endOfDay = outputDate.with(LocalTime.MAX);
         }
+        if(null != frameTimeStr){
+            // 解析frameTimeStr格式为 "HH:mm:ss-HH:mm:ss"
+            String[] times = frameTimeStr.split("-");
+            if(times.length == 2) {
+                LocalTime customStartTime = LocalTime.parse(times[0]);
+                LocalTime customEndTime = LocalTime.parse(times[1]);
+                // 将自定义时间应用到有效时间范围
+                startOfDay = now.with(customStartTime);
+                endOfDay = now.with(customEndTime);
+            }
+        }
         AddUserRequestDTO addUserRequestDTO = new AddUserRequestDTO();
         List<AddUserRequestDTO.DoorRightPlan> doorRightPlans = new ArrayList<>();
         AddUserRequestDTO.DoorRightPlan doorRightPlan = new AddUserRequestDTO.DoorRightPlan();