ソースを参照

添加家长访客预约审核和其他访客预约审核

liu 2 年 前
コミット
4ed27dbb3e

+ 4 - 1
src/main/java/com/template/api/SmartVisitorControllerAPI.java

@@ -132,8 +132,11 @@ public interface SmartVisitorControllerAPI {
     CommonResult getPage(@RequestParam int currentPage, @RequestParam int pageCount,@RequestParam Integer type,String keyWord,Integer status,String startTime,String endTime,String visitorStartTime,String visitorEndTime);
     CommonResult getPage(@RequestParam int currentPage, @RequestParam int pageCount,@RequestParam Integer type,String keyWord,Integer status,String startTime,String endTime,String visitorStartTime,String visitorEndTime);
 
 
     @GetMapping(value = "/parentsAudit")
     @GetMapping(value = "/parentsAudit")
-    @ApiOperation(value = "家长审核", notes = "家长审核", httpMethod = "GET")
+    @ApiOperation(value = "家长访问预约审核", notes = "家长访客预约审核", httpMethod = "GET")
     CommonResult parentsAudit(@RequestParam int id,@RequestParam int type);
     CommonResult parentsAudit(@RequestParam int id,@RequestParam int type);
 
 
+    @GetMapping(value = "/restsAudit")
+    @ApiOperation(value = "其他访问预约审核", notes = "其他访客预约审核", httpMethod = "GET")
+    CommonResult restsAudit(@RequestParam int id,@RequestParam int type);
 
 
 }
 }

+ 123 - 124
src/main/java/com/template/controller/SmartFaceDiscernController.java

@@ -254,154 +254,153 @@ public class SmartFaceDiscernController implements SmartFaceDiscernControllerAPI
             //                比对时间
             //                比对时间
             String time = jsonObject.getString("time");
             String time = jsonObject.getString("time");
             logger.info("time = " + time);
             logger.info("time = " + time);
-            LocalDateTime localDateTime = LocalDateTime.now().withHour(0).withSecond(0).withMinute(0);
-            LocalDateTime localDateTime2 = LocalDateTime.parse(time, dateTimeFormatter1);
-//            只获取当天的
-            if (localDateTime.isBefore(localDateTime2)) {
+//            LocalDateTime localDateTime = LocalDateTime.now().withHour(0).withSecond(0).withMinute(0);
+//            LocalDateTime localDateTime2 = LocalDateTime.parse(time, dateTimeFormatter1);
+////            只获取当天的
+//            if (localDateTime.isBefore(localDateTime2)) {
 //            比对结果
 //            比对结果
-                Integer resultStatus = jsonObject.getInteger("resultStatus");
+            Integer resultStatus = jsonObject.getInteger("resultStatus");
 //                if (1 == resultStatus) {
 //                if (1 == resultStatus) {
 
 
-                    //          设备sn
-                    String sn = jsonObject.getString("sn");
-                    SmartDevice smartDevice = smartDeviceService.getNum(sn);
-                    String address = "";
-                    String type = "";
-                    if (ObjectUtils.isNotEmpty(smartDevice)) {
-                        //            地点
-                        address = smartDevice.getAddress();
+            //          设备sn
+            String sn = jsonObject.getString("sn");
+            SmartDevice smartDevice = smartDeviceService.getNum(sn);
+            String address = "";
+            String type = "";
+            if (ObjectUtils.isNotEmpty(smartDevice)) {
+                //            地点
+                address = smartDevice.getAddress();
 //            类型
 //            类型
-                        type = smartDevice.getName();
-                    }
+                type = smartDevice.getName();
+            }
 
 
 //            名字,学生会加班级[]
 //            名字,学生会加班级[]
-                    String name = jsonObject.getString("name");
-                    System.out.println("name = " + name);
-                    String[] split = name.split("\\[");
-                    String s = split[0];
-                    logger.info("name = " + s);
+            String name = jsonObject.getString("name");
+            System.out.println("name = " + name);
+            String[] split = name.split("\\[");
+            String s = split[0];
+            logger.info("name = " + s);
 //            百胜门禁编号
 //            百胜门禁编号
-                    String idNum = jsonObject.getString("idNum");
-                    logger.info("idNum = " + idNum);
-                    SmartUser smartUser = smartUserService.getBsStudentNo(idNum);
-                    Integer userId = 0;
-                    if (ObjectUtils.isNotEmpty(smartUser)) {
-                        userId = smartUser.getId();
-                    } else {
-                        userId = 0;
-                    }
+            String idNum = jsonObject.getString("idNum");
+            logger.info("idNum = " + idNum);
+            SmartUser smartUser = smartUserService.getBsStudentNo(idNum);
+            Integer userId = 0;
+            if (ObjectUtils.isNotEmpty(smartUser)) {
+                userId = smartUser.getId();
+            } else {
+                userId = 0;
+            }
 
 
 //                    出入标识: 1-进, 0-出
 //                    出入标识: 1-进, 0-出
-                    Integer inout = jsonObject.getInteger("inout");
+            Integer inout = jsonObject.getInteger("inout");
 //                    开门方式:0-白名单比对,1-人证比对,2-IC卡比对
 //                    开门方式:0-白名单比对,1-人证比对,2-IC卡比对
-                    Integer openType = jsonObject.getInteger("openType");
-
-                    SmartAccess smartFaceDiscern = new SmartAccess();
-
-                    smartFaceDiscern.setName(s);
-                    smartFaceDiscern.setLocation(address);
-                    smartFaceDiscern.setType(type);
-                    smartFaceDiscern.setUserId(userId);
-                    smartFaceDiscern.setDateTime(time);
-                    smartFaceDiscern.setIdNum(idNum);
-                    smartFaceDiscern.setSn(sn);
-                    smartFaceDiscern.setInout(inout);
-                    smartFaceDiscern.setOpenType(openType);
-                    smartFaceDiscern.setResultStatus(resultStatus);
-                    if (userId != 0) {
-                        //                    判断是否已经添加
-                        LambdaQueryWrapper<SmartAccess> wrapperFD = new LambdaQueryWrapper<>();
-                        wrapperFD.eq(SmartAccess::getDateTime, smartFaceDiscern.getDateTime())
-                                .eq(SmartAccess::getUserId, userId);
-                        List<SmartAccess> list = smartAccessService.list(wrapperFD);
-                        if (ObjectUtils.isEmpty(list) && list.size() == 0) {
-                            //          抓拍的照片 base64字符串
-                            String scenePhoto = jsonObject.getString("scenePhoto");
-                            scenePhoto = "data:image/jpeg;base64," + scenePhoto;
-                            logger.info("scenePhoto =" + scenePhoto.substring(0, 50));
+            Integer openType = jsonObject.getInteger("openType");
+
+            SmartAccess smartFaceDiscern = new SmartAccess();
+
+            smartFaceDiscern.setName(s);
+            smartFaceDiscern.setLocation(address);
+            smartFaceDiscern.setType(type);
+            smartFaceDiscern.setUserId(userId);
+            smartFaceDiscern.setDateTime(time);
+            smartFaceDiscern.setIdNum(idNum);
+            smartFaceDiscern.setSn(sn);
+            smartFaceDiscern.setInOut(inout);
+            smartFaceDiscern.setOpenType(openType);
+            smartFaceDiscern.setResultStatus(resultStatus);
+            if (userId != 0) {
+                //                    判断是否已经添加
+                LambdaQueryWrapper<SmartAccess> wrapperFD = new LambdaQueryWrapper<>();
+                wrapperFD.eq(SmartAccess::getDateTime, smartFaceDiscern.getDateTime())
+                        .eq(SmartAccess::getUserId, userId);
+                List<SmartAccess> list = smartAccessService.list(wrapperFD);
+                if (ObjectUtils.isEmpty(list) && list.size() == 0) {
+                    //          抓拍的照片 base64字符串
+                    String scenePhoto = jsonObject.getString("scenePhoto");
+                    scenePhoto = "data:image/jpeg;base64," + scenePhoto;
+                    logger.info("scenePhoto =" + scenePhoto.substring(0, 50));
 //            base64转文件
 //            base64转文件
-                            MultipartFile multipartFile = MultipartFileUtils.base64ToMultipartFile(scenePhoto);
-                            String image="";
-                            try {
-                                //            上传到cos桶,并生成图片地址
-                                 image = smartUploadService.upload(new MultipartFile[]{multipartFile});
-                            }catch (Exception e){
-                                e.printStackTrace();
-                                logger.error("上传cos桶失败");
-                            }
+                    MultipartFile multipartFile = MultipartFileUtils.base64ToMultipartFile(scenePhoto);
+                    String image = "";
+                    try {
+                        //            上传到cos桶,并生成图片地址
+                        image = smartUploadService.upload(new MultipartFile[]{multipartFile});
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                        logger.error("上传cos桶失败");
+                    }
 
 
-                            smartFaceDiscern.setImage(image);
-                            smartAccessService.save(smartFaceDiscern);
+                    smartFaceDiscern.setImage(image);
+                    smartAccessService.save(smartFaceDiscern);
 
 
 //                        通过学生id找到关联的家长affiliate,并找到公众号,如果openid为空则不传
 //                        通过学生id找到关联的家长affiliate,并找到公众号,如果openid为空则不传
-                            List<SmartUser> userList = smartUserService.getAffiliateList(userId);
-                            if (ObjectUtils.isNotEmpty(userList) && userList.size() > 0) {
-
-                                for (SmartUser user : userList) {
-                                    String gzhOpenId = user.getGzhOpenId();
-                                    if (ObjectUtils.isNotEmpty(gzhOpenId)) {
-                                        String pushType = "";
-                                        if (type.contains("进校")) {
-                                            pushType = "进入大门";
-                                        } else if (type.contains("出校")) {
-                                            pushType = "离开大门";
-                                        }
-                                        LocalDateTime date = LocalDateTime.now();
-                                        String format = date.format(dateTimeFormatter1);
-                                        //                    公众号信息推送
-                                        Message2.send(gzhOpenId, pushType, address, format);
-
-                                        SmartNotification smartNotification = new SmartNotification();
-                                        smartNotification.setUserId(smartUser.getId());
-                                        smartNotification.setUserName(smartUser.getName());
-                                        smartNotification.setTypeName(pushType);
-                                        smartNotification.setLocation(address);
-                                        smartNotification.setImage(image);
-                                        smartNotification.setDateTime(time);
-                                        smartNotification.setType(2);
-
-                                        smartNotificationService.save(smartNotification);
-
-                                    }
-
+                    List<SmartUser> userList = smartUserService.getAffiliateList(userId);
+                    if (ObjectUtils.isNotEmpty(userList) && userList.size() > 0) {
+
+                        for (SmartUser user : userList) {
+                            String gzhOpenId = user.getGzhOpenId();
+                            if (ObjectUtils.isNotEmpty(gzhOpenId)) {
+                                String pushType = "";
+                                if (type.contains("进校")) {
+                                    pushType = "进入大门";
+                                } else if (type.contains("出校")) {
+                                    pushType = "离开大门";
                                 }
                                 }
+                                LocalDateTime date = LocalDateTime.now();
+                                String format = date.format(dateTimeFormatter1);
+                                //                    公众号信息推送
+                                Message2.send(gzhOpenId, pushType, address, format);
+
+                                SmartNotification smartNotification = new SmartNotification();
+                                smartNotification.setUserId(smartUser.getId());
+                                smartNotification.setUserName(smartUser.getName());
+                                smartNotification.setTypeName(pushType);
+                                smartNotification.setLocation(address);
+                                smartNotification.setImage(image);
+                                smartNotification.setDateTime(time);
+                                smartNotification.setType(2);
+
+                                smartNotificationService.save(smartNotification);
+
                             }
                             }
+
                         }
                         }
-                    } else {
+                    }
+                }
+            } else {
 
 
-                        smartFaceDiscern.setUserId(0);
+                smartFaceDiscern.setUserId(0);
 //                    判断是否已经添加
 //                    判断是否已经添加
-                        LambdaQueryWrapper<SmartAccess> wrapperFD = new LambdaQueryWrapper<>();
-                        wrapperFD.eq(SmartAccess::getDateTime, time)
-                                .eq(SmartAccess::getName, s)
-                                .eq(SmartAccess::getType, type);
-                        List<SmartAccess> list = smartAccessService.list(wrapperFD);
-
-                        if (ObjectUtils.isEmpty(list) && list.size() == 0) {
-                            //          抓拍的照片 base64字符串
-                            String scenePhoto = jsonObject.getString("scenePhoto");
-                            scenePhoto = "data:image/jpeg;base64," + scenePhoto;
-                            logger.info("scenePhoto =" + scenePhoto.substring(0, 50));
+                LambdaQueryWrapper<SmartAccess> wrapperFD = new LambdaQueryWrapper<>();
+                wrapperFD.eq(SmartAccess::getDateTime, time)
+                        .eq(SmartAccess::getName, s)
+                        .eq(SmartAccess::getType, type);
+                List<SmartAccess> list = smartAccessService.list(wrapperFD);
+
+                if (ObjectUtils.isEmpty(list) && list.size() == 0) {
+                    //          抓拍的照片 base64字符串
+                    String scenePhoto = jsonObject.getString("scenePhoto");
+                    scenePhoto = "data:image/jpeg;base64," + scenePhoto;
+                    logger.info("scenePhoto =" + scenePhoto.substring(0, 50));
 //            base64转文件
 //            base64转文件
-                            MultipartFile multipartFile = MultipartFileUtils.base64ToMultipartFile(scenePhoto);
-                            String image="";
-                            try {
-                                //            上传到cos桶,并生成图片地址
-                                image = smartUploadService.upload(new MultipartFile[]{multipartFile});
-                            }catch (Exception e){
-                                e.printStackTrace();
-                                logger.error("上传cos桶失败");
-                            }
-                            smartFaceDiscern.setImage(image);
-                            smartAccessService.save(smartFaceDiscern);
-                        }
-
+                    MultipartFile multipartFile = MultipartFileUtils.base64ToMultipartFile(scenePhoto);
+                    String image = "";
+                    try {
+                        //            上传到cos桶,并生成图片地址
+                        image = smartUploadService.upload(new MultipartFile[]{multipartFile});
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                        logger.error("上传cos桶失败");
                     }
                     }
+                    smartFaceDiscern.setImage(image);
+                    smartAccessService.save(smartFaceDiscern);
                 }
                 }
+
+            }
+//            }
 //            }
 //            }
 
 
-        } catch (
-                Exception e) {
+        } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
             JSONObject r = new JSONObject();
             JSONObject r = new JSONObject();
             r.put("message", "Success");
             r.put("message", "Success");

+ 225 - 16
src/main/java/com/template/controller/SmartVisitorController.java

@@ -231,26 +231,26 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
             Integer schoolClass = smartUser.getSchoolClass();
             Integer schoolClass = smartUser.getSchoolClass();
             SmartVisitorParentsConfig svpc = smartVisitorParentsConfigService.getById(schoolClass);
             SmartVisitorParentsConfig svpc = smartVisitorParentsConfigService.getById(schoolClass);
             Integer appAuditConfig = svpc.getAppAuditConfig();
             Integer appAuditConfig = svpc.getAppAuditConfig();
-            if (1==appAuditConfig) {//需要审核
+            if (1 == appAuditConfig) {//需要审核
                 sv.setStatu(1);
                 sv.setStatu(1);
-            }else {//不需要审核
+            } else {//不需要审核
                 Integer appPushConfig = svpc.getAppPushConfig();
                 Integer appPushConfig = svpc.getAppPushConfig();
 //                判断是否需要推送
 //                判断是否需要推送
-                if (5==appPushConfig) {//需要推送
+                if (5 == appPushConfig) {//需要推送
                     String content = sv.getRespondentName() + "你的家长将于" + TimeExchange.chineseDateTime(sv.getVisitorTime()) + "到校!";
                     String content = sv.getRespondentName() + "你的家长将于" + TimeExchange.chineseDateTime(sv.getVisitorTime()) + "到校!";
                     //将预约信息推送到希沃班牌
                     //将预约信息推送到希沃班牌
                     CommonResult seewo = pushInfo(sv.getUserPhone(), sv.getResponcode(), content);
                     CommonResult seewo = pushInfo(sv.getUserPhone(), sv.getResponcode(), content);
                 }
                 }
 //                核销
 //                核销
                 Integer appCancelConfig = svpc.getAppCancelConfig();
                 Integer appCancelConfig = svpc.getAppCancelConfig();
-                if (6==appCancelConfig) {//需要核销
+                if (6 == appCancelConfig) {//需要核销
                     sv.setStatu(7);
                     sv.setStatu(7);
-                }else {//不需要核销
+                } else {//不需要核销
                     sv.setStatu(9);
                     sv.setStatu(9);
                 }
                 }
 //                门禁配置
 //                门禁配置
                 Integer accessConfig = svpc.getAccessConfig();
                 Integer accessConfig = svpc.getAccessConfig();
-                if (0==accessConfig) {
+                if (0 == accessConfig) {
                     try {
                     try {
                         if (!ObjectUtils.isEmpty(sv.getCarNum())) {
                         if (!ObjectUtils.isEmpty(sv.getCarNum())) {
                             String appId = parkConfig.getAppId();
                             String appId = parkConfig.getAppId();
@@ -315,7 +315,6 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
         }
         }
 
 
 
 
-
         boolean result = smartVisitorService.insertVisitorBatch(svs);
         boolean result = smartVisitorService.insertVisitorBatch(svs);
 
 
         return result ? CommonResult.ok("预约成功,等待审批通过") : CommonResult.fail("预约失败");
         return result ? CommonResult.ok("预约成功,等待审批通过") : CommonResult.fail("预约失败");
@@ -365,12 +364,12 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
         List<SmartVisitorRestsConfig> list = smartVisitorRestsConfigService.list(new LambdaQueryWrapper<>());
         List<SmartVisitorRestsConfig> list = smartVisitorRestsConfigService.list(new LambdaQueryWrapper<>());
         SmartVisitorRestsConfig smartVisitorRestsConfig = list.get(0);
         SmartVisitorRestsConfig smartVisitorRestsConfig = list.get(0);
         Integer auditConfig = smartVisitorRestsConfig.getAuditConfig();
         Integer auditConfig = smartVisitorRestsConfig.getAuditConfig();
-        if (1==auditConfig) {//需要审核
+        if (1 == auditConfig) {//需要审核
             sv.setStatu(1);
             sv.setStatu(1);
-        }else if (9==auditConfig){
+        } else if (9 == auditConfig) {
             sv.setStatu(9);
             sv.setStatu(9);
             Integer accessConfig = smartVisitorRestsConfig.getAccessConfig();
             Integer accessConfig = smartVisitorRestsConfig.getAccessConfig();
-            if (0==accessConfig) {//推送到门禁
+            if (0 == accessConfig) {//推送到门禁
                 try {
                 try {
                     if (!ObjectUtils.isEmpty(sv.getCarNum())) {
                     if (!ObjectUtils.isEmpty(sv.getCarNum())) {
                         String appId = parkConfig.getAppId();
                         String appId = parkConfig.getAppId();
@@ -428,7 +427,7 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
 
 
                     //发送短信给其他访客用户
                     //发送短信给其他访客用户
                     if (!ObjectUtils.isEmpty(sv.getVisitorCode())) {
                     if (!ObjectUtils.isEmpty(sv.getVisitorCode())) {
-                        String message = SendSms.sendVisitorSms("+86" + sv.getUserPhone(), TimeExchange.getYear(sv.getVisitorTime()), TimeExchange.getMonth(sv.getVisitorTime()), TimeExchange.getDay(sv.getVisitorTime()), TimeExchange.getTime(sv.getVisitorTime()), TimeExchange.getTime(sv.getVisitorDeadline()),sv.getVisitorCode());
+                        String message = SendSms.sendVisitorSms("+86" + sv.getUserPhone(), TimeExchange.getYear(sv.getVisitorTime()), TimeExchange.getMonth(sv.getVisitorTime()), TimeExchange.getDay(sv.getVisitorTime()), TimeExchange.getTime(sv.getVisitorTime()), TimeExchange.getTime(sv.getVisitorDeadline()), sv.getVisitorCode());
                         if (!message.contains("success")) {
                         if (!message.contains("success")) {
                             throw new Exception("发送失败");
                             throw new Exception("发送失败");
                         }
                         }
@@ -603,15 +602,225 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
 
 
     @Override
     @Override
     @DESRespondSecret(validated = false)
     @DESRespondSecret(validated = false)
-    public CommonResult getPage(int currentPage, int pageCount,Integer type, String keyWord, Integer status, String startTime, String endTime,String visitorStartTime,String visitorEndTime) {
-       PageUtils<SmartVisitor> page= smartVisitorService.getPage(currentPage,pageCount,type,keyWord,status,startTime,endTime,visitorStartTime,visitorEndTime);
+    public CommonResult getPage(int currentPage, int pageCount, Integer type, String keyWord, Integer status, String startTime, String endTime, String visitorStartTime, String visitorEndTime) {
+        PageUtils<SmartVisitor> page = smartVisitorService.getPage(currentPage, pageCount, type, keyWord, status, startTime, endTime, visitorStartTime, visitorEndTime);
 
 
         return CommonResult.ok(page);
         return CommonResult.ok(page);
     }
     }
 
 
     @Override
     @Override
     public CommonResult parentsAudit(int id, int type) {
     public CommonResult parentsAudit(int id, int type) {
-        return null;
+        SmartVisitor sv = smartVisitorService.getSmartById(id);
+        if (sv == null) {
+            return CommonResult.fail("访客记录已失效,审核失败!");
+        }
+
+        //审核处理后的数据不能再处理判断
+        if (sv.getStatu().intValue() != eApproveStatu.Audit.getValue()) {
+            return CommonResult.fail("该记录已被操作过,请勿重复操作");
+        }
+        try {
+//            同意
+            if (type == 4) {
+                //        获取受访者id
+                Integer respondent = sv.getRespondent();
+                SmartUser smartUser = smartUserService.getById(respondent);
+                Integer schoolClass = smartUser.getSchoolClass();
+                SmartVisitorParentsConfig svpc = smartVisitorParentsConfigService.getById(schoolClass);
+                Integer appPushConfig = svpc.getAppPushConfig();
+//                判断是否需要推送
+                if (5 == appPushConfig) {//需要推送
+                    String content = sv.getRespondentName() + "你的家长将于" + TimeExchange.chineseDateTime(sv.getVisitorTime()) + "到校!";
+                    //将预约信息推送到希沃班牌
+                    CommonResult seewo = pushInfo(sv.getUserPhone(), sv.getResponcode(), content);
+                }
+//                核销
+                Integer appCancelConfig = svpc.getAppCancelConfig();
+                if (6 == appCancelConfig) {//需要核销
+                    sv.setStatu(7);
+                } else {//不需要核销
+                    sv.setStatu(9);
+                }
+//                门禁配置
+                Integer accessConfig = svpc.getAccessConfig();
+                if (0 == accessConfig) {
+
+                    if (!ObjectUtils.isEmpty(sv.getCarNum())) {
+                        String appId = parkConfig.getAppId();
+                        String carNo = sv.getCarNum();
+                        String parkKey = parkConfig.getParkKey();
+                        String rand = String.valueOf(Math.random());
+                        String reserveTime = TimeExchange.DateToString(sv.getVisitorTime(), "yyyy-MM-dd HH:mm:ss");
+                        String reserveEndTime = TimeExchange.DateToString(sv.getVisitorDeadline(), "yyyy-MM-dd HH:mm:ss");
+                        String version = "v1.0";
+                        String appSecret = parkConfig.getAppSecret();
+                        String url = parkConfig.getUrl() + "Inform/Reservation";
+
+                        JSONObject jsonobject = new JSONObject();
+                        jsonobject.put("appid", appId);
+                        jsonobject.put("carNo", carNo);
+                        jsonobject.put("parkKey", parkKey);
+                        jsonobject.put("rand", rand);
+                        jsonobject.put("reserveEndTime", reserveEndTime);
+                        jsonobject.put("reserveTime", reserveTime);
+                        jsonobject.put("version", "v1.0");
+
+                        //appid=ymdd36ed157ac423e2&carNo=赣U123659&parkKey=wdcmq9rc&rand=9.94995525689689966&reserveEndTime=2023-12-22 20:12:10&reserveTime=2023-12-21 18:12:10&version=v1.0&50596cd243dc4547b4c05f01f8ea02a4
+                        String md5Str = "appid=" + appId + "&carNo=" + carNo + "&parkKey=" + parkKey + "&rand=" + rand + "&reserveEndTime=" + reserveEndTime + "&reserveTime=" + reserveTime + "&version=" + version + "&" + appSecret;
+                        String sign = CommonUtil.MD5(md5Str);
+                        //sign签名
+                        jsonobject.put("sign", sign);
+
+                        //返回的结果中 code为1表示成功
+                        String result = RequestUtils.httpPost(url, jsonobject.toJSONString());
+
+                        logger.info(result);
+
+                        if (!result.contains("预约成功")) {
+                            throw new Exception("审核失败");
+                        }
+
+                        ObjectMapper objectMapper = new ObjectMapper();
+                        BsReservationVo reservation = objectMapper.readValue(result, BsReservationVo.class);
+                        sv.setBsOrderNo(reservation.getData().getReOrderNo());
+                    } else {
+                        //查找用户是否存在
+                        SmartUser user = smartUserService.getSmartById(sv.getUserId());
+                        if (user == null) {
+                            throw new Exception("访客用户ID在系统中不存在,无法将访客信息下发到门禁设备!");
+                        }
+                        List<SmartDevice> devices = smartDeviceService.queryOnLineDevice();
+                        String visitorNo = getUUIDBits(16);
+                        //region 将访客数据下发到设备
+                        for (SmartDevice device : devices) {
+                            CommonResult<String> insertVisitor = bsInsertVisitor(user, TimeExchange.DateToString(sv.getVisitorTime()), TimeExchange.DateToString(sv.getVisitorDeadline()), device.getNum(), visitorNo);
+                            if (!insertVisitor.isSuccess()) {
+                                throw new Exception(insertVisitor.getMessage());
+                            }
+                            sv.setVisitorsync(sv.getVisitorsync() == null ? insertVisitor.getData() : (sv.getVisitorsync() + "," + insertVisitor.getData()));
+                            sv.setDeviceNum(sv.getDeviceNum() == null ? device.getNum() : (sv.getDeviceNum() + "," + device.getNum()));
+                        }
+                        String code = GetVertifyCode.getRandomNumCode(6);
+                        sv.setVisitorCode(code);
+                    }
+
+                }
+
+            } else if (type == 2) {//拒绝
+                sv.setStatu(2);
+            }
+            int result = smartVisitorService.updateSmartVisitor(sv);
+            if (result <= 0) {
+                throw new Exception("审核失败");
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+
+        return CommonResult.ok("审核成功");
+    }
+
+    @Override
+    public CommonResult restsAudit(int id, int type) {
+        SmartVisitor sv = smartVisitorService.getSmartById(id);
+        if (sv == null) {
+            return CommonResult.fail("访客记录已失效,审核失败!");
+        }
+
+        //审核处理后的数据不能再处理判断
+        if (sv.getStatu().intValue() != eApproveStatu.Audit.getValue()) {
+            return CommonResult.fail("该记录已被操作过,请勿重复操作");
+        }
+
+        try {
+            //            同意
+            if (type == 4) {
+                sv.setStatu(9);
+                List<SmartVisitorRestsConfig> list = smartVisitorRestsConfigService.list(new LambdaQueryWrapper<>());
+                SmartVisitorRestsConfig smartVisitorRestsConfig = list.get(0);
+                Integer accessConfig = smartVisitorRestsConfig.getAccessConfig();
+                if (0 == accessConfig) {
+                    //推送到门禁
+                    if (!ObjectUtils.isEmpty(sv.getCarNum())) {
+                        String appId = parkConfig.getAppId();
+                        String carNo = sv.getCarNum();
+                        String parkKey = parkConfig.getParkKey();
+                        String rand = String.valueOf(Math.random());
+                        String reserveTime = TimeExchange.DateToString(sv.getVisitorTime(), "yyyy-MM-dd HH:mm:ss");
+                        String reserveEndTime = TimeExchange.DateToString(sv.getVisitorDeadline(), "yyyy-MM-dd HH:mm:ss");
+                        String version = "v1.0";
+                        String appSecret = parkConfig.getAppSecret();
+                        String url = parkConfig.getUrl() + "Inform/Reservation";
+
+                        JSONObject jsonobject = new JSONObject();
+                        jsonobject.put("appid", appId);
+                        jsonobject.put("carNo", carNo);
+                        jsonobject.put("parkKey", parkKey);
+                        jsonobject.put("rand", rand);
+                        jsonobject.put("reserveEndTime", reserveEndTime);
+                        jsonobject.put("reserveTime", reserveTime);
+                        jsonobject.put("version", "v1.0");
+
+                        //appid=ymdd36ed157ac423e2&carNo=赣U123659&parkKey=wdcmq9rc&rand=9.94995525689689966&reserveEndTime=2023-12-22 20:12:10&reserveTime=2023-12-21 18:12:10&version=v1.0&50596cd243dc4547b4c05f01f8ea02a4
+                        String md5Str = "appid=" + appId + "&carNo=" + carNo + "&parkKey=" + parkKey + "&rand=" + rand + "&reserveEndTime=" + reserveEndTime + "&reserveTime=" + reserveTime + "&version=" + version + "&" + appSecret;
+                        String sign = CommonUtil.MD5(md5Str);
+                        //sign签名
+                        jsonobject.put("sign", sign);
+
+                        //返回的结果中 code为1表示成功
+                        String result = RequestUtils.httpPost(url, jsonobject.toJSONString());
+
+                        logger.info(result);
+
+                        if (!result.contains("预约成功")) {
+                            throw new Exception("审核失败");
+                        }
+
+                        ObjectMapper objectMapper = new ObjectMapper();
+                        BsReservationVo reservation = objectMapper.readValue(result, BsReservationVo.class);
+                        sv.setBsOrderNo(reservation.getData().getReOrderNo());
+                    } else {
+                        List<SmartDevice> devices = smartDeviceService.queryOnLineDevice();
+                        String visitorNo = getUUIDBits(16);
+                        //region 将访客数据下发到设备
+                        for (SmartDevice device : devices) {
+                            //查找用户是否存在
+                            SmartUser user = smartUserService.getSmartById(sv.getUserId());
+                            if (user == null) {
+                                throw new Exception("访客用户ID在系统中不存在,无法将访客信息下发到门禁设备!");
+                            }
+                            CommonResult<String> insertVisitor = bsInsertVisitor(user, TimeExchange.DateToString(sv.getVisitorTime()), TimeExchange.DateToString(sv.getVisitorDeadline()), device.getNum(), visitorNo);
+                            if (!insertVisitor.isSuccess()) {
+                                throw new Exception(insertVisitor.getMessage());
+                            }
+                            sv.setVisitorsync(sv.getVisitorsync() == null ? insertVisitor.getData() : (sv.getVisitorsync() + "," + insertVisitor.getData()));
+                            sv.setDeviceNum(sv.getDeviceNum() == null ? device.getNum() : (sv.getDeviceNum() + "," + device.getNum()));
+                        }
+                        String code = GetVertifyCode.getRandomNumCode(6);
+                        sv.setVisitorCode(code);
+                    }
+
+                    //发送短信给其他访客用户
+                    if (!ObjectUtils.isEmpty(sv.getVisitorCode())) {
+                        String message = SendSms.sendVisitorSms("+86" + sv.getUserPhone(), TimeExchange.getYear(sv.getVisitorTime()), TimeExchange.getMonth(sv.getVisitorTime()), TimeExchange.getDay(sv.getVisitorTime()), TimeExchange.getTime(sv.getVisitorTime()), TimeExchange.getTime(sv.getVisitorDeadline()), sv.getVisitorCode());
+                        if (!message.contains("success")) {
+                            throw new Exception("发送失败");
+                        }
+                    }
+
+                }
+            } else if (type == 2) {//拒绝
+                sv.setStatu(2);
+            }
+            int result = smartVisitorService.updateSmartVisitor(sv);
+            if (result <= 0) {
+                throw new Exception("审核失败");
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+
+        return CommonResult.ok("审核成功");
     }
     }
 
 
     /**
     /**
@@ -916,7 +1125,7 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
                 case 1://家长
                 case 1://家长
                     //查找是否存在访客记录
                     //查找是否存在访客记录
                     SmartVisitor visitor = smartVisitorService.queryParentVisitor(user.getId());
                     SmartVisitor visitor = smartVisitorService.queryParentVisitor(user.getId());
-                    if(visitor == null){
+                    if (visitor == null) {
                         logger.info("无访客数据,家长无法通行");
                         logger.info("无访客数据,家长无法通行");
                         result.setResultcode(2);
                         result.setResultcode(2);
                         result.setMessage("无访客数据,家长无法通行");
                         result.setMessage("无访客数据,家长无法通行");
@@ -967,7 +1176,7 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
             //访客码中的ID是访客数据的ID
             //访客码中的ID是访客数据的ID
             //查找是否存在访客记录
             //查找是否存在访客记录
             SmartVisitor visitor = smartVisitorService.getSmartById(qiv.getId());
             SmartVisitor visitor = smartVisitorService.getSmartById(qiv.getId());
-            if(visitor == null){
+            if (visitor == null) {
                 logger.info("无访客数据,访客无法通行");
                 logger.info("无访客数据,访客无法通行");
                 result.setResultcode(2);
                 result.setResultcode(2);
                 result.setMessage("无访客数据,访客无法通行");
                 result.setMessage("无访客数据,访客无法通行");

+ 2 - 0
src/main/java/com/template/mapper/SmartAccessMapper.java

@@ -2,6 +2,7 @@ package com.template.mapper;
 
 
 import com.template.model.pojo.SmartAccess;
 import com.template.model.pojo.SmartAccess;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springframework.stereotype.Repository;
 
 
 /**
 /**
  * <p>
  * <p>
@@ -11,6 +12,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @author ceshi
  * @author ceshi
  * @since 2024-05-31
  * @since 2024-05-31
  */
  */
+@Repository
 public interface SmartAccessMapper extends BaseMapper<SmartAccess> {
 public interface SmartAccessMapper extends BaseMapper<SmartAccess> {
 
 
 }
 }

+ 1 - 1
src/main/java/com/template/model/pojo/SmartAccess.java

@@ -61,7 +61,7 @@ public class SmartAccess implements Serializable {
     private String dateTime;
     private String dateTime;
 
 
     @ApiModelProperty(value = "出入标识: 1-进, 0-出")
     @ApiModelProperty(value = "出入标识: 1-进, 0-出")
-    private Integer inout;
+    private Integer inOut;
 
 
     @ApiModelProperty(value = "开门方式:0-白名单比对,1-人证比对,2-IC卡比对")
     @ApiModelProperty(value = "开门方式:0-白名单比对,1-人证比对,2-IC卡比对")
     private Integer openType;
     private Integer openType;

+ 0 - 1
src/main/java/com/template/services/SmartAccessService.java

@@ -14,7 +14,6 @@ import java.util.List;
  * @author ceshi
  * @author ceshi
  * @since 2024-05-31
  * @since 2024-05-31
  */
  */
-@Repository
 public interface SmartAccessService extends IService<SmartAccess> {
 public interface SmartAccessService extends IService<SmartAccess> {
 
 
     List<SmartAccess> track(String stateTime, String endTime, Integer id);
     List<SmartAccess> track(String stateTime, String endTime, Integer id);