pj访客
This commit is contained in:
1 parent
a895c16ee2
commit
cf667b8960
3 files changed
+117
-114
No files matched your search
+115
@@ -7,11 +7,17 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.core.constant.CacheConstants;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.idempotent.annotation.Idempotent;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.common.security.annotation.Inner;
|
||||
import com.bsd.pjcloud.flow.task.constant.TaskCheckStatusEnum;
|
||||
import com.bsd.pjcloud.integrated.dto.visitor.app.VisitorsAppDTO;
|
||||
import com.bsd.pjcloud.integrated.entity.CarInfoEntity;
|
||||
import com.bsd.pjcloud.integrated.entity.VisitorUserEntity;
|
||||
import com.bsd.pjcloud.integrated.entity.VisitorsEntity;
|
||||
import com.bsd.pjcloud.integrated.service.VisitorUserService;
|
||||
import com.bsd.pjcloud.integrated.service.VisitorsService;
|
||||
import com.bsd.pjcloud.integrated.vo.visitor.app.VisitorsAppVo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -27,6 +33,9 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import cn.hutool.extra.qrcode.QrConfig;
|
||||
import java.awt.Image;
|
||||
import cn.hutool.core.img.ImgUtil;
|
||||
|
||||
/**
|
||||
* 访客用户
|
||||
@@ -56,4 +65,110 @@ public class AppVisitorController {
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "app新增访客" , description = "app新增访客" )
|
||||
@SysLog("新增访客" )
|
||||
@PostMapping("/app/save")
|
||||
@Idempotent(expireTime = 10, info = "请勿重复提交")
|
||||
public R saveFK(@RequestBody VisitorsAppDTO visitors) {
|
||||
return R.ok(visitorsService.vistorsSave(visitors));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据token查询预约的信息
|
||||
* 通过token查询访客表
|
||||
* @param
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过token查询" , description = "通过token查询" )
|
||||
@GetMapping("/app/get/visitorDetail" )
|
||||
public R<VisitorsAppVo> getByToken(@RequestParam("token") String token) {
|
||||
|
||||
return R.ok(visitorsService.getByToken(token));
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫码发送请求确认是否能通过
|
||||
* 通过token查询访客表
|
||||
* @param
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过token查询" , description = "通过token查询" )
|
||||
@PostMapping("/app/verify" )
|
||||
public R checkByToken(@RequestParam("token" ) String token) {
|
||||
|
||||
LambdaQueryWrapper<VisitorsEntity> visitorsEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
visitorsEntityLambdaQueryWrapper.eq(VisitorsEntity::getToken,token);
|
||||
visitorsEntityLambdaQueryWrapper.eq(VisitorsEntity::getCheckStatus, TaskCheckStatusEnum.RESULT);
|
||||
VisitorsEntity visitors = visitorsService.getOne(visitorsEntityLambdaQueryWrapper);
|
||||
if (visitors == null){
|
||||
return R.failed("没有此预约信息");
|
||||
}
|
||||
LocalDateTime vStartDate = visitors.getVStartDate();
|
||||
if (vStartDate.isBefore(LocalDateTime.now())){
|
||||
return R.failed("预约时间未到");
|
||||
}
|
||||
LocalDateTime vEndDate = visitors.getVEndDate();
|
||||
if (vEndDate.isBefore(LocalDateTime.now())){
|
||||
return R.failed("预约已过期");
|
||||
}
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取动态二维码(用于门卫/机器核验,5分钟刷新一次,预约未过期时一直可用)
|
||||
* @param token uuid生成的
|
||||
* @param logoUrl 可选logo图片url
|
||||
*/
|
||||
@GetMapping("/app/visitorQr")
|
||||
public R<Map<String, Object>> getVisitorQr(
|
||||
@RequestParam("token") String token,
|
||||
@RequestParam(value = "logoUrl", required = false) String logoUrl
|
||||
) {
|
||||
// 1. 查访客预约,判断token是否有效且未过期
|
||||
VisitorsAppVo visitor = visitorsService.getByToken(token);
|
||||
if (visitor == null) return R.failed("无效token");
|
||||
if (visitor.getVEndDate() == null || visitor.getVEndDate().isBefore(java.time.LocalDateTime.now())) return R.failed("预约已过期");
|
||||
|
||||
// 2. 生成动态部分(每5分钟变化一次)
|
||||
long now5Min = System.currentTimeMillis() / (1000 * 60 * 5);
|
||||
String secret = "your-visitor-qr-secret";
|
||||
String sign = cn.hutool.crypto.SecureUtil.hmacSha256(secret).digestHex(token + now5Min);
|
||||
|
||||
// 3. 二维码内容
|
||||
String qrContent = token + ":" + now5Min + ":" + sign;
|
||||
|
||||
// 4. 配置二维码参数
|
||||
QrConfig qrConfig = new QrConfig(300, 300);
|
||||
String targetType = "png";
|
||||
Image logo = null;
|
||||
if (logoUrl != null && !logoUrl.isEmpty()) {
|
||||
try {
|
||||
logo = ImgUtil.read(logoUrl);
|
||||
} catch (Exception e) {
|
||||
// logo读取失败可忽略
|
||||
}
|
||||
}
|
||||
String qrBase64 = cn.hutool.extra.qrcode.QrCodeUtil.generateAsBase64(qrContent, qrConfig, targetType, logo);
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("qrBase64", qrBase64);
|
||||
result.put("expireSeconds", 300); // 5分钟后自动刷新
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
@GetMapping("/app/sq/page")
|
||||
@SysLog("获取我的新增记录" )
|
||||
public R getPage(@ParameterObject Page page, @ParameterObject VisitorsEntity visitors) {
|
||||
return R.ok( visitorsService.getPageSQ(page, visitors));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/app/cancelVisitor")
|
||||
@SysLog("取消访客预约" )
|
||||
public R cancelVisitor(@RequestParam("id")Long id) {
|
||||
return R.ok( visitorsService.cancelVisitor(id));
|
||||
}
|
||||
|
||||
}
|
||||
-62
@@ -129,59 +129,8 @@ public class VisitorsController {
|
||||
|
||||
|
||||
//-----------------------APP----------------------------
|
||||
/**
|
||||
* 新增访客表
|
||||
* @param visitors 访客表
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "app新增访客" , description = "app新增访客" )
|
||||
@SysLog("新增访客" )
|
||||
@PostMapping("/app/save")
|
||||
@Idempotent(expireTime = 10, info = "请勿重复提交")
|
||||
public R saveFK(@RequestBody VisitorsAppDTO visitors) {
|
||||
return R.ok(visitorsService.vistorsSave(visitors));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据token查询预约的信息
|
||||
* 通过token查询访客表
|
||||
* @param
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过token查询" , description = "通过token查询" )
|
||||
@GetMapping("/app/get/visitorDetail" )
|
||||
public R<VisitorsAppVo> getByToken(@RequestParam("token") String token) {
|
||||
|
||||
return R.ok(visitorsService.getByToken(token));
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫码发送请求确认是否能通过
|
||||
* 通过token查询访客表
|
||||
* @param
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过token查询" , description = "通过token查询" )
|
||||
@PostMapping("/app/verify" )
|
||||
public R checkByToken(@RequestParam("token" ) String token) {
|
||||
|
||||
LambdaQueryWrapper<VisitorsEntity> visitorsEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
visitorsEntityLambdaQueryWrapper.eq(VisitorsEntity::getToken,token);
|
||||
visitorsEntityLambdaQueryWrapper.eq(VisitorsEntity::getCheckStatus, TaskCheckStatusEnum.RESULT);
|
||||
VisitorsEntity visitors = visitorsService.getOne(visitorsEntityLambdaQueryWrapper);
|
||||
if (visitors == null){
|
||||
return R.failed("没有此预约信息");
|
||||
}
|
||||
LocalDateTime vStartDate = visitors.getVStartDate();
|
||||
if (vStartDate.isBefore(LocalDateTime.now())){
|
||||
return R.failed("预约时间未到");
|
||||
}
|
||||
LocalDateTime vEndDate = visitors.getVEndDate();
|
||||
if (vEndDate.isBefore(LocalDateTime.now())){
|
||||
return R.failed("预约已过期");
|
||||
}
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -199,22 +148,11 @@ public class VisitorsController {
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/app/sq/page")
|
||||
@SysLog("获取我的新增记录" )
|
||||
public R getPage(@ParameterObject Page page, @ParameterObject VisitorsEntity visitors) {
|
||||
return R.ok( visitorsService.getPageSQ(page, visitors));
|
||||
}
|
||||
@GetMapping("/app/yy/page")
|
||||
@SysLog("获取我的邀约记录" )
|
||||
public R getPageBF(@ParameterObject Page page, @ParameterObject VisitorsEntity visitors) {
|
||||
return R.ok( visitorsService.getPageYY(page, visitors));
|
||||
}
|
||||
|
||||
@GetMapping("/app/cancelVisitor")
|
||||
@SysLog("取消访客预约" )
|
||||
public R cancelVisitor(@RequestParam("id")Long id) {
|
||||
return R.ok( visitorsService.cancelVisitor(id));
|
||||
}
|
||||
@GetMapping("/app/haveVisitor")
|
||||
@SysLog("已到访" )
|
||||
public R haveVisitor(@RequestParam("id")Long id) {
|
||||
|
||||
+2
-52
@@ -77,8 +77,6 @@ public class VisitorsServiceImpl extends ServiceImpl<VisitorsMapper, VisitorsEnt
|
||||
|
||||
private final RemoteUserService remoteUserService;
|
||||
|
||||
private final RemoteFlowApiFlowService remoteFlowApiFlowService;
|
||||
|
||||
private final VisitorsPeopleMapper visitorsPeopleMapper;
|
||||
|
||||
private final RemoteDictService remoteDictService;
|
||||
@@ -104,13 +102,8 @@ public class VisitorsServiceImpl extends ServiceImpl<VisitorsMapper, VisitorsEnt
|
||||
// }
|
||||
// String processInstanceId = stringR.getData();
|
||||
|
||||
// 1.发起海康预约接口获取预约结果
|
||||
List<VisitorInfo> visitorInfoList = new ArrayList<>();
|
||||
VisitorInfo visitorInfo = new VisitorInfo();
|
||||
VisitorAppointmentRequest visitorAppointmentRequest = new VisitorAppointmentRequest();
|
||||
visitorAppointmentRequest.setReceptionistId(visitors.getReceiveId().toString());
|
||||
visitorAppointmentRequest.setVisitStartTime((TimeUtils.LocalDateTimeToISO8601(visitors.getVStartDate())));
|
||||
visitorAppointmentRequest.setVisitEndTime(TimeUtils.LocalDateTimeToISO8601(visitors.getVEndDate()));
|
||||
visitorInfo.setVisitorName(visitors.getName());
|
||||
visitorInfo.setPhoneNo(visitors.getMobile());
|
||||
visitorInfoList.add(visitorInfo);
|
||||
@@ -167,35 +160,11 @@ public class VisitorsServiceImpl extends ServiceImpl<VisitorsMapper, VisitorsEnt
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
visitorAppointmentRequest.setVisitorInfoList(visitorInfoList);
|
||||
VisitorObjectResponse<AppointmentData> visitorAppointment = remoterVisitorService.createVisitorAppointment(visitorAppointmentRequest);
|
||||
AppointmentData appointmentData = visitorAppointment.getData();
|
||||
String appointRecordId = appointmentData.getAppointRecordId();
|
||||
bean.setAppointRecordId(appointRecordId);
|
||||
List<AppointmentInfo> appointmentInfoList = appointmentData.getAppointmentInfoList();
|
||||
AppointmentInfo mainAppointmentInfo = appointmentInfoList.get(0);
|
||||
bean.setOrderId(mainAppointmentInfo.getOrderId());
|
||||
bean.setQrcode(mainAppointmentInfo.getQRCode());
|
||||
bean.setVerificationCode(mainAppointmentInfo.getVerificationCode());
|
||||
|
||||
//大于1说明还有访客,取出访客
|
||||
List<AppointmentInfo> sxAppointmentInfos = appointmentInfoList.stream()
|
||||
.skip(1)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
int insert = baseMapper.insert(bean);
|
||||
if (!CollectionUtils.isEmpty(visitorsPeopleAppDTOList)){
|
||||
List<VisitorsPeopleEntity> visitorsPeopleEntities = BeanUtils.toBean(visitorsPeopleAppDTOList, VisitorsPeopleEntity.class);
|
||||
for (int i = 0; i < visitorsPeopleEntities.size(); i++){
|
||||
VisitorsPeopleEntity visitorsPeopleEntity = visitorsPeopleEntities.get(i);
|
||||
if (!CollectionUtils.isEmpty(sxAppointmentInfos)){
|
||||
AppointmentInfo appointmentInfo = sxAppointmentInfos.get(i);
|
||||
visitorsPeopleEntity.setOrderId(appointmentInfo.getOrderId());
|
||||
visitorsPeopleEntity.setQrcode(appointmentInfo.getQRCode());
|
||||
visitorsPeopleEntity.setVerificationCode(appointmentInfo.getVerificationCode());
|
||||
}
|
||||
|
||||
visitorsPeopleEntity.setVisitorsId(bean.getId());
|
||||
|
||||
}
|
||||
@@ -222,26 +191,8 @@ public class VisitorsServiceImpl extends ServiceImpl<VisitorsMapper, VisitorsEnt
|
||||
VisitorsAppVo bean = BeanUtils.toBean(visitors, VisitorsAppVo.class);
|
||||
|
||||
// 只有当审核状态为审核通过(check_status=2)时,才携带qrcode相关信息
|
||||
if (TaskCheckStatusEnum.RESULT.getCode().equals(visitors.getCheckStatus())|| TaskCheckStatusEnum.HAVE_VISIT.getCode().equals(visitors.getCheckStatus())) {
|
||||
// 清除qrcode相关字段
|
||||
// bean.setQrcode(null);
|
||||
//调用查询二维码的接口
|
||||
QueryAppointmentRecordsRequest queryAppointmentRecordsRequest = new QueryAppointmentRecordsRequest();
|
||||
queryAppointmentRecordsRequest.setPageNo(1);
|
||||
queryAppointmentRecordsRequest.setPageSize(1);
|
||||
queryAppointmentRecordsRequest.setOrderId(visitors.getOrderId());
|
||||
queryAppointmentRecordsRequest.setVerificationCode(visitors.getVerificationCode());
|
||||
R<QueryAppointmentRecordsResponse> queryAppointmentRecordsResponseR = remoterVisitorService.queryAppointmentRecords(queryAppointmentRecordsRequest);
|
||||
QueryAppointmentRecordsResponse queryAppointmentRecordsResponse = queryAppointmentRecordsResponseR.getData();
|
||||
QueryAppointmentRecordsResponse.QueryRecordsData queryRecordsData = queryAppointmentRecordsResponse.getData();
|
||||
List<QueryAppointmentRecordsResponse.AppointmentRecord> list = queryRecordsData.getList();
|
||||
if (!CollectionUtils.isEmpty(list)){
|
||||
QueryAppointmentRecordsResponse.AppointmentRecord appointmentRecord = list.get(0);
|
||||
bean.setQrcode(appointmentRecord.getQRCode());
|
||||
}else {
|
||||
throw new ServiceException("二维码接口获取失败");
|
||||
}
|
||||
// bean.setVerificationCode(null);
|
||||
if (!TaskCheckStatusEnum.RESULT.getCode().equals(visitors.getCheckStatus())) {
|
||||
bean.setQrcode(null);
|
||||
}
|
||||
|
||||
List<VisitorsCarEntity> visitorsCarEntities =
|
||||
@@ -262,7 +213,6 @@ public class VisitorsServiceImpl extends ServiceImpl<VisitorsMapper, VisitorsEnt
|
||||
peopleVo.setVerificationCode(null);
|
||||
});
|
||||
}
|
||||
|
||||
bean.setVisitorsPeopleAppVos(visitorsPeopleAppVos);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user