|
|
@@ -231,26 +231,26 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
|
|
|
Integer schoolClass = smartUser.getSchoolClass();
|
|
|
SmartVisitorParentsConfig svpc = smartVisitorParentsConfigService.getById(schoolClass);
|
|
|
Integer appAuditConfig = svpc.getAppAuditConfig();
|
|
|
- if (1==appAuditConfig) {//需要审核
|
|
|
+ if (1 == appAuditConfig) {//需要审核
|
|
|
sv.setStatu(1);
|
|
|
- }else {//不需要审核
|
|
|
+ } else {//不需要审核
|
|
|
Integer appPushConfig = svpc.getAppPushConfig();
|
|
|
// 判断是否需要推送
|
|
|
- if (5==appPushConfig) {//需要推送
|
|
|
+ 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) {//需要核销
|
|
|
+ if (6 == appCancelConfig) {//需要核销
|
|
|
sv.setStatu(7);
|
|
|
- }else {//不需要核销
|
|
|
+ } else {//不需要核销
|
|
|
sv.setStatu(9);
|
|
|
}
|
|
|
// 门禁配置
|
|
|
Integer accessConfig = svpc.getAccessConfig();
|
|
|
- if (0==accessConfig) {
|
|
|
+ if (0 == accessConfig) {
|
|
|
try {
|
|
|
if (!ObjectUtils.isEmpty(sv.getCarNum())) {
|
|
|
String appId = parkConfig.getAppId();
|
|
|
@@ -315,7 +315,6 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
boolean result = smartVisitorService.insertVisitorBatch(svs);
|
|
|
|
|
|
return result ? CommonResult.ok("预约成功,等待审批通过") : CommonResult.fail("预约失败");
|
|
|
@@ -365,12 +364,12 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
|
|
|
List<SmartVisitorRestsConfig> list = smartVisitorRestsConfigService.list(new LambdaQueryWrapper<>());
|
|
|
SmartVisitorRestsConfig smartVisitorRestsConfig = list.get(0);
|
|
|
Integer auditConfig = smartVisitorRestsConfig.getAuditConfig();
|
|
|
- if (1==auditConfig) {//需要审核
|
|
|
+ if (1 == auditConfig) {//需要审核
|
|
|
sv.setStatu(1);
|
|
|
- }else if (9==auditConfig){
|
|
|
+ } else if (9 == auditConfig) {
|
|
|
sv.setStatu(9);
|
|
|
Integer accessConfig = smartVisitorRestsConfig.getAccessConfig();
|
|
|
- if (0==accessConfig) {//推送到门禁
|
|
|
+ if (0 == accessConfig) {//推送到门禁
|
|
|
try {
|
|
|
if (!ObjectUtils.isEmpty(sv.getCarNum())) {
|
|
|
String appId = parkConfig.getAppId();
|
|
|
@@ -428,7 +427,7 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
|
|
|
|
|
|
//发送短信给其他访客用户
|
|
|
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")) {
|
|
|
throw new Exception("发送失败");
|
|
|
}
|
|
|
@@ -603,15 +602,225 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
|
|
|
|
|
|
@Override
|
|
|
@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);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
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://家长
|
|
|
//查找是否存在访客记录
|
|
|
SmartVisitor visitor = smartVisitorService.queryParentVisitor(user.getId());
|
|
|
- if(visitor == null){
|
|
|
+ if (visitor == null) {
|
|
|
logger.info("无访客数据,家长无法通行");
|
|
|
result.setResultcode(2);
|
|
|
result.setMessage("无访客数据,家长无法通行");
|
|
|
@@ -967,7 +1176,7 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
|
|
|
//访客码中的ID是访客数据的ID
|
|
|
//查找是否存在访客记录
|
|
|
SmartVisitor visitor = smartVisitorService.getSmartById(qiv.getId());
|
|
|
- if(visitor == null){
|
|
|
+ if (visitor == null) {
|
|
|
logger.info("无访客数据,访客无法通行");
|
|
|
result.setResultcode(2);
|
|
|
result.setMessage("无访客数据,访客无法通行");
|