|
@@ -3,6 +3,7 @@ package com.template.controller;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
@@ -83,6 +84,11 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
|
|
|
@Resource
|
|
@Resource
|
|
|
private ParkConfig parkConfig;
|
|
private ParkConfig parkConfig;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ SmartVisitorParentsConfigService smartVisitorParentsConfigService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ SmartVisitorRestsConfigService smartVisitorRestsConfigService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 新增访客预约
|
|
* 新增访客预约
|
|
@@ -209,7 +215,7 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
|
|
|
sv.setPeerNum(par.getPeerNum());
|
|
sv.setPeerNum(par.getPeerNum());
|
|
|
sv.setCarNum(par.getCarNum());
|
|
sv.setCarNum(par.getCarNum());
|
|
|
sv.setVisitReason(par.getVisitReason());
|
|
sv.setVisitReason(par.getVisitReason());
|
|
|
- sv.setStatu(eApproveStatu.Audit.getValue());
|
|
|
|
|
|
|
+// sv.setStatu(eApproveStatu.Audit.getValue());
|
|
|
sv.setVisitorTime(TimeExchange.StringToDate(par.getVisitorTime(), "yyyy-MM-dd HH:mm:ss"));
|
|
sv.setVisitorTime(TimeExchange.StringToDate(par.getVisitorTime(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
sv.setVisitorDeadline(TimeExchange.StringToDate(TimeExchange.AddTimeDesH(sv.getVisitorTime(), 4), "yyyy-MM-dd HH:mm:ss"));
|
|
sv.setVisitorDeadline(TimeExchange.StringToDate(TimeExchange.AddTimeDesH(sv.getVisitorTime(), 4), "yyyy-MM-dd HH:mm:ss"));
|
|
|
sv.setRespondent(student.getId());
|
|
sv.setRespondent(student.getId());
|
|
@@ -218,14 +224,103 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
|
|
|
//将第一个受访学生的部门ID带过去
|
|
//将第一个受访学生的部门ID带过去
|
|
|
sv.setDepartmentId(student.getDepartmentId());
|
|
sv.setDepartmentId(student.getDepartmentId());
|
|
|
sv.setVisitorType(eVisitorType.Parent.getValue());
|
|
sv.setVisitorType(eVisitorType.Parent.getValue());
|
|
|
|
|
+
|
|
|
|
|
+ // 获取受访者id
|
|
|
|
|
+ Integer respondent = sv.getRespondent();
|
|
|
|
|
+ SmartUser smartUser = smartUserService.getById(respondent);
|
|
|
|
|
+ Integer schoolClass = smartUser.getSchoolClass();
|
|
|
|
|
+ SmartVisitorParentsConfig svpc = smartVisitorParentsConfigService.getById(schoolClass);
|
|
|
|
|
+ Integer appAuditConfig = svpc.getAppAuditConfig();
|
|
|
|
|
+ if (1 == appAuditConfig) {//需要审核
|
|
|
|
|
+ sv.setStatu(1);
|
|
|
|
|
+ } else {//不需要审核
|
|
|
|
|
+ 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) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ 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) {
|
|
|
|
|
+ CommonResult<String> insertVisitor = bsInsertVisitor(su, 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);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
svs.add(sv);
|
|
svs.add(sv);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
boolean result = smartVisitorService.insertVisitorBatch(svs);
|
|
boolean result = smartVisitorService.insertVisitorBatch(svs);
|
|
|
|
|
|
|
|
return result ? CommonResult.ok("预约成功,等待审批通过") : CommonResult.fail("预约失败");
|
|
return result ? CommonResult.ok("预约成功,等待审批通过") : CommonResult.fail("预约失败");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
@DESRespondSecret(validated = true)
|
|
@DESRespondSecret(validated = true)
|
|
|
public CommonResult otherAppointment(otherAppointmentRequest oar, BindingResult bindingResult) {
|
|
public CommonResult otherAppointment(otherAppointmentRequest oar, BindingResult bindingResult) {
|
|
@@ -259,13 +354,92 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
|
|
|
sv.setPeerNum(oar.getPeerNum());
|
|
sv.setPeerNum(oar.getPeerNum());
|
|
|
sv.setCarNum(oar.getCarNum());
|
|
sv.setCarNum(oar.getCarNum());
|
|
|
sv.setVisitReason(oar.getVisitReason());
|
|
sv.setVisitReason(oar.getVisitReason());
|
|
|
- sv.setStatu(eApproveStatu.Audit.getValue());
|
|
|
|
|
|
|
+// sv.setStatu(eApproveStatu.Audit.getValue());
|
|
|
sv.setVisitorTime(TimeExchange.StringToDate(startTime, "yyyy-MM-dd HH:mm:ss"));
|
|
sv.setVisitorTime(TimeExchange.StringToDate(startTime, "yyyy-MM-dd HH:mm:ss"));
|
|
|
sv.setVisitorDeadline(TimeExchange.StringToDate(endTime, "yyyy-MM-dd HH:mm:ss"));
|
|
sv.setVisitorDeadline(TimeExchange.StringToDate(endTime, "yyyy-MM-dd HH:mm:ss"));
|
|
|
sv.setRespondentName(oar.getRespondentName());
|
|
sv.setRespondentName(oar.getRespondentName());
|
|
|
sv.setRespondentPhone(oar.getRespondentPhone());
|
|
sv.setRespondentPhone(oar.getRespondentPhone());
|
|
|
sv.setVisitorType(eVisitorType.Other.getValue());
|
|
sv.setVisitorType(eVisitorType.Other.getValue());
|
|
|
|
|
|
|
|
|
|
+ List<SmartVisitorRestsConfig> list = smartVisitorRestsConfigService.list(new LambdaQueryWrapper<>());
|
|
|
|
|
+ SmartVisitorRestsConfig smartVisitorRestsConfig = list.get(0);
|
|
|
|
|
+ Integer auditConfig = smartVisitorRestsConfig.getAuditConfig();
|
|
|
|
|
+ if (1 == auditConfig) {//需要审核
|
|
|
|
|
+ sv.setStatu(1);
|
|
|
|
|
+ } else if (9 == auditConfig) {
|
|
|
|
|
+ sv.setStatu(9);
|
|
|
|
|
+ Integer accessConfig = smartVisitorRestsConfig.getAccessConfig();
|
|
|
|
|
+ if (0 == accessConfig) {//推送到门禁
|
|
|
|
|
+ try {
|
|
|
|
|
+ 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) {
|
|
|
|
|
+ CommonResult<String> insertVisitor = bsInsertVisitor(su, 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("发送失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
int result = smartVisitorService.insertSmartVisitor(sv);
|
|
int result = smartVisitorService.insertSmartVisitor(sv);
|
|
|
|
|
|
|
|
return result > 0 ? CommonResult.ok("预约成功,等待审批通过") : CommonResult.ok("预约失败");
|
|
return result > 0 ? CommonResult.ok("预约成功,等待审批通过") : CommonResult.ok("预约失败");
|
|
@@ -428,12 +602,227 @@ 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
|
|
|
|
|
+ public CommonResult parentsAudit(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) {
|
|
|
|
|
+ // 获取受访者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("审核成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 1、学生请假:
|
|
* 1、学生请假:
|
|
|
* 我们这边调用请假接口之后,把请假数据写到了百胜系统的"学生请假登记"页面中,那到时候学生是通过任意设备都能进出吗?
|
|
* 我们这边调用请假接口之后,把请假数据写到了百胜系统的"学生请假登记"页面中,那到时候学生是通过任意设备都能进出吗?
|
|
@@ -736,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("无访客数据,家长无法通行");
|
|
@@ -787,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("无访客数据,访客无法通行");
|