双屏消费机-人脸特征值、设备信息接口
This commit is contained in:
parent
a019db6d13
commit
4498029f6c
|
|
@ -0,0 +1,33 @@
|
|||
package com.bonus.canteen.core.android.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.bonus.canteen.core.android.dto.AppDTO;
|
||||
import com.bonus.canteen.core.android.service.DeviceService;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
@Api(tags = "android-双屏消费机-设备信息")
|
||||
@RestController
|
||||
@RequestMapping("/api/android/device")
|
||||
public class DeviceController {
|
||||
@Autowired
|
||||
private DeviceService deviceService;
|
||||
|
||||
|
||||
|
||||
@ApiOperation("获取设备信息")
|
||||
@RequestMapping("/getDeviceInfo")
|
||||
public AjaxResult getDeviceInfo(@RequestBody AppDTO dto) {
|
||||
if (ObjectUtil.isEmpty(dto.getDeviceSn())) {
|
||||
throw new ServiceException("设备sn不能为空");
|
||||
}
|
||||
return deviceService.getDeviceInfo(dto);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.bonus.canteen.core.android.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.bonus.canteen.core.android.dto.AppDTO;
|
||||
import com.bonus.canteen.core.android.service.FaceService;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Api(tags = "android-双屏消费机-人脸特征值")
|
||||
@RestController
|
||||
@RequestMapping("/api/android/face")
|
||||
public class FaceController {
|
||||
@Autowired
|
||||
private FaceService faceService;
|
||||
|
||||
@ApiOperation("获取人脸特征值")
|
||||
@RequestMapping("/getFaceFeatureList")
|
||||
public AjaxResult getFaceFeatureList(@RequestBody AppDTO dto) {
|
||||
try {
|
||||
return faceService.getFaceFeatureList(dto);
|
||||
}catch (ServiceException e){
|
||||
return AjaxResult.error("获取人脸特征值失败!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.bonus.canteen.core.android.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AppDTO {
|
||||
|
||||
/**
|
||||
* 设备sn码
|
||||
*/
|
||||
private String deviceSn;
|
||||
|
||||
private String time;
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.bonus.canteen.core.android.mapper;
|
||||
|
||||
import com.bonus.canteen.core.android.dto.AppDTO;
|
||||
import com.bonus.canteen.core.android.vo.DeviceInfoVo;
|
||||
import com.bonus.canteen.core.device.dto.DeviceDTO;
|
||||
import com.bonus.canteen.core.device.dto.DeviceSearchDTO;
|
||||
import com.bonus.canteen.core.device.vo.DeviceFullInfoVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备绑定多档口子Mapper接口
|
||||
*
|
||||
* @author xsheng
|
||||
* @date 2025-04-03
|
||||
*/
|
||||
public interface DeviceMapper {
|
||||
/**
|
||||
* 查询设备信息
|
||||
*
|
||||
* @param dto
|
||||
* @return 设备绑定多档口子
|
||||
*/
|
||||
DeviceInfoVo getDeviceInfo(AppDTO dto);
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.bonus.canteen.core.android.mapper;
|
||||
|
||||
import com.bonus.canteen.core.android.dto.AppDTO;
|
||||
import com.bonus.canteen.core.user.domain.UserFace;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface FaceMapper {
|
||||
List<UserFace> getFaceFeatureList(AppDTO dto);
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.bonus.canteen.core.android.service;
|
||||
|
||||
import com.bonus.canteen.core.android.dto.AppDTO;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
|
||||
public interface DeviceService {
|
||||
AjaxResult getDeviceInfo(AppDTO dto);
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.bonus.canteen.core.android.service;
|
||||
|
||||
import com.bonus.canteen.core.android.dto.AppDTO;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
|
||||
public interface FaceService {
|
||||
AjaxResult getFaceFeatureList(AppDTO dto);
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package com.bonus.canteen.core.android.service.impl;
|
||||
|
||||
import com.bonus.canteen.core.android.dto.AppDTO;
|
||||
import com.bonus.canteen.core.android.mapper.DeviceMapper;
|
||||
import com.bonus.canteen.core.android.service.DeviceService;
|
||||
import com.bonus.canteen.core.android.vo.DeviceInfoVo;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.houqin.constant.GlobalConstants;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class DeviceServiceImpl implements DeviceService {
|
||||
@Autowired
|
||||
private DeviceMapper mapper;
|
||||
|
||||
|
||||
@Value("${face.android.appId}")
|
||||
private String appId;
|
||||
@Value("${face.android.sdkKey}")
|
||||
private String appKey;
|
||||
|
||||
@Override
|
||||
public AjaxResult getDeviceInfo(AppDTO dto) {
|
||||
//判断设备是否存在
|
||||
DeviceInfoVo deviceInfoVo = mapper.getDeviceInfo(dto);
|
||||
if (deviceInfoVo == null){
|
||||
return AjaxResult.error("设备不存在");
|
||||
}
|
||||
deviceInfoVo.setAppId(appId);
|
||||
deviceInfoVo.setAppKey(appKey);
|
||||
deviceInfoVo.setTenantId(String.valueOf(GlobalConstants.TENANT_ID));
|
||||
return AjaxResult.success(deviceInfoVo);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.bonus.canteen.core.android.service.impl;
|
||||
|
||||
import com.bonus.canteen.core.android.dto.AppDTO;
|
||||
import com.bonus.canteen.core.android.mapper.FaceMapper;
|
||||
import com.bonus.canteen.core.android.service.FaceService;
|
||||
import com.bonus.canteen.core.user.domain.UserFace;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service
|
||||
public class FaceServiceImpl implements FaceService {
|
||||
@Autowired
|
||||
private FaceMapper mapper;
|
||||
@Override
|
||||
public AjaxResult getFaceFeatureList(AppDTO dto) {
|
||||
List<UserFace> list = mapper.getFaceFeatureList(dto);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.bonus.canteen.core.android.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DeviceInfoVo {
|
||||
|
||||
private String tenantId;
|
||||
|
||||
private String appId;
|
||||
|
||||
private String appKey;
|
||||
|
||||
private String areaId;
|
||||
private String areaName;
|
||||
private String canteenId;
|
||||
private String stallId;
|
||||
private String canteenName;
|
||||
private String stallName;
|
||||
private String recipeId;
|
||||
private String deviceNum;
|
||||
private String deviceName;
|
||||
private String devicePwd;
|
||||
}
|
||||
|
|
@ -1,39 +1,22 @@
|
|||
package com.bonus.canteen.core.device.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||
import com.bonus.canteen.core.alloc.domain.AllocCanteen;
|
||||
import com.bonus.canteen.core.alloc.domain.AllocStall;
|
||||
import com.bonus.canteen.core.alloc.mapper.AllocCanteenMapper;
|
||||
import com.bonus.canteen.core.alloc.mapper.AllocStallMapper;
|
||||
import com.bonus.canteen.core.device.domain.DeviceBind;
|
||||
import com.bonus.canteen.core.device.domain.DeviceInfo;
|
||||
import com.bonus.canteen.core.device.dto.DeviceDTO;
|
||||
import com.bonus.canteen.core.device.dto.DeviceSearchDTO;
|
||||
import com.bonus.canteen.core.device.service.IDoubleScreenMachineService;
|
||||
import com.bonus.canteen.core.device.vo.DeviceFullInfoVO;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.houqin.constant.DelFlagEnum;
|
||||
import com.bonus.common.houqin.constant.LeConstants;
|
||||
import com.bonus.common.houqin.constant.SourceTypeEnum;
|
||||
import com.bonus.common.houqin.utils.BRequest;
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
import com.github.pagehelper.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.bonus.common.log.annotation.SysLog;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.core.web.page.TableDataInfo;
|
||||
|
|
@ -123,11 +106,11 @@ public class DoubleScreenMachineController extends BaseController {
|
|||
}
|
||||
@ApiOperation(value = "更新设备在线状态")
|
||||
@PostMapping({"/updateTimeBySn"})
|
||||
public AjaxResult updateTimeBySn(@RequestParam String sn) {
|
||||
if (ObjectUtil.isEmpty(sn)) {
|
||||
public AjaxResult updateTimeBySn(@RequestBody DeviceSearchDTO dto) {
|
||||
if (ObjectUtil.isEmpty(dto.getDeviceSn())) {
|
||||
throw new ServiceException("设备sn不能为空");
|
||||
}
|
||||
this.screenMachineService.updateTimeBySn(sn);
|
||||
this.screenMachineService.updateTimeBySn(dto.getDeviceSn());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
package com.bonus.canteen.core.user.domain;
|
||||
|
||||
import com.bonus.common.core.utils.DateUtils;
|
||||
import groovy.transform.ToString;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
public class DeviceMqPersonalUpdateMessageDTO {
|
||||
@ApiModelProperty("是否更新人员")
|
||||
private Integer updatePerson;
|
||||
|
|
@ -17,6 +18,16 @@ public class DeviceMqPersonalUpdateMessageDTO {
|
|||
private Long time;
|
||||
@ApiModelProperty("是否更新有效期照片1更新")
|
||||
private Integer updateValidityPhoto;
|
||||
@ApiModelProperty("当前时间")
|
||||
private String currentTime;
|
||||
|
||||
public void setCurrentTime(String currentTime) {
|
||||
this.currentTime = currentTime;
|
||||
}
|
||||
|
||||
public String getCurrentTime() {
|
||||
return DateUtils.getTime();
|
||||
}
|
||||
|
||||
public Long getTime() {
|
||||
return Instant.now().toEpochMilli();
|
||||
|
|
@ -42,35 +53,53 @@ public class DeviceMqPersonalUpdateMessageDTO {
|
|||
return this.updateValidityPhoto;
|
||||
}
|
||||
|
||||
|
||||
public DeviceMqPersonalUpdateMessageDTO setUpdatePerson(final Integer updatePerson) {
|
||||
this.currentTime = DateUtils.getTime();
|
||||
this.updatePerson = updatePerson;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DeviceMqPersonalUpdateMessageDTO setUpdatePersonPhoto(final Integer updatePersonPhoto) {
|
||||
this.currentTime = DateUtils.getTime();
|
||||
this.updatePersonPhoto = updatePersonPhoto;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DeviceMqPersonalUpdateMessageDTO setUpdateCardStatus(final Integer updateCardStatus) {
|
||||
this.currentTime = DateUtils.getTime();
|
||||
this.updateCardStatus = updateCardStatus;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DeviceMqPersonalUpdateMessageDTO setIsAccBalChange(final Integer isAccBalChange) {
|
||||
this.currentTime = DateUtils.getTime();
|
||||
this.isAccBalChange = isAccBalChange;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DeviceMqPersonalUpdateMessageDTO setTime(final Long time) {
|
||||
this.currentTime = DateUtils.getTime();
|
||||
this.time = time;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DeviceMqPersonalUpdateMessageDTO setUpdateValidityPhoto(final Integer updateValidityPhoto) {
|
||||
this.currentTime = DateUtils.getTime();
|
||||
this.updateValidityPhoto = updateValidityPhoto;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DeviceMqPersonalUpdateMessageDTO{" +
|
||||
"updatePerson=" + updatePerson +
|
||||
", updatePersonPhoto=" + updatePersonPhoto +
|
||||
", updateCardStatus=" + updateCardStatus +
|
||||
", isAccBalChange=" + isAccBalChange +
|
||||
", time=" + time +
|
||||
", updateValidityPhoto=" + updateValidityPhoto +
|
||||
", currentTime='" + currentTime + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.canteen.core.user.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
|
|
@ -7,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
|||
import com.bonus.common.core.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
|
||||
|
|
@ -22,7 +24,7 @@ import javax.validation.constraints.NotBlank;
|
|||
|
||||
@Data
|
||||
@ToString
|
||||
public class UserFace extends BaseEntity {
|
||||
public class UserFace implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键自增 */
|
||||
|
|
@ -69,4 +71,11 @@ public class UserFace extends BaseEntity {
|
|||
/** 删除标志(0代表存在 2代表删除) */
|
||||
private String delFlag;
|
||||
|
||||
private String createBy;
|
||||
|
||||
private String createTime;
|
||||
|
||||
private String updateBy;
|
||||
|
||||
private String updateTime;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,10 @@ public class UserFaceServiceImpl implements IUserFaceService {
|
|||
faceVO.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
|
||||
faceVO.setUserId(dto.getUserId());
|
||||
faceVO.setPhotoUrl(dto.getPhotoUrl());
|
||||
faceVO.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
|
||||
faceVO.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
|
||||
faceVO.setCreateTime(DateUtils.getTime());
|
||||
faceVO.setUpdateTime(DateUtils.getTime());
|
||||
list.add(faceVO);
|
||||
System.out.println("faceResult.getFeatures():" + Base64.getEncoder().encodeToString(faceResult.getFeatures()));
|
||||
System.out.println("人脸采集成功");
|
||||
|
|
@ -74,8 +78,10 @@ public class UserFaceServiceImpl implements IUserFaceService {
|
|||
if (code == 0){
|
||||
throw new ServiceException("[虹软算法]:保存失败");
|
||||
}
|
||||
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePersonPhoto(1);
|
||||
System.out.println(bean.toString());
|
||||
//发送mq
|
||||
MqUtil.pushToTenantAllDevice((new DeviceMqPersonalUpdateMessageDTO()).setUpdatePersonPhoto(1), LeMqConstant.Topic.DEVICE_UPDATE_PERSONAL_CONFIG_V4);
|
||||
// MqUtil.pushToTenantAllDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_PERSONAL_CONFIG_V4);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.canteen.core.android.mapper.DeviceMapper">
|
||||
<select id="getDeviceInfo" resultType="com.bonus.canteen.core.android.vo.DeviceInfoVo">
|
||||
SELECT di.device_num AS deviceNum,
|
||||
di.device_name AS deviceName,
|
||||
dr.recipe_id AS recipeId,
|
||||
dr.recipe_name AS recipeName,
|
||||
CONCAT(aaa.area_name, '/', aa.area_name) AS areaName,
|
||||
aa.area_id AS areaId,
|
||||
ac.canteen_name AS canteenName,
|
||||
ac.canteen_id AS canteenId,
|
||||
ast.stall_name AS stallName,
|
||||
ast.stall_id AS stallId,
|
||||
di.device_pwd as devicePwd
|
||||
FROM device_info di
|
||||
LEFT JOIN device_bind db ON di.device_id = db.device_id
|
||||
left join alloc_area aa on db.area_id = aa.area_id
|
||||
left join alloc_area aaa on aaa.area_id = aa.parent_id
|
||||
LEFT JOIN alloc_canteen ac ON db.canteen_id = ac.canteen_id
|
||||
LEFT JOIN alloc_stall ast ON db.stall_id = ast.stall_id
|
||||
LEFT JOIN (SELECT dr.device_id, mr.recipe_name,mr.recipe_id
|
||||
FROM device_recipe dr
|
||||
LEFT JOIN menu_recipe mr ON dr.recipe_id = mr.recipe_id) dr
|
||||
ON di.device_id = dr.device_id
|
||||
where di.device_sn = #{deviceSn}
|
||||
GROUP BY di.device_id
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.canteen.core.android.mapper.FaceMapper">
|
||||
<select id="getFaceFeatureList" resultType="com.bonus.canteen.core.user.domain.UserFace">
|
||||
select
|
||||
user_id,
|
||||
photo_url,
|
||||
features,
|
||||
face_state
|
||||
from user_face
|
||||
where del_flag = '0'
|
||||
<if test="time != null and time != ''">
|
||||
and update_time >= #{time} - INTERVAL 5 SECOND;
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -4,11 +4,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.canteen.core.user.mapper.UserFaceMapper">
|
||||
<insert id="insert">
|
||||
insert into user_face(user_id,photo_url,features,create_by,error_msg)
|
||||
values(#{userId},#{photoUrl},#{features},#{createBy},#{errorMsg})
|
||||
insert into user_face(user_id,photo_url,features,create_by,error_msg,create_time,update_by,update_time)
|
||||
values(#{userId},#{photoUrl},#{features},#{createBy},#{errorMsg},#{createTime},#{updateBy},#{updateTime})
|
||||
on duplicate key update features = #{features},
|
||||
photo_url = #{photoUrl},
|
||||
error_msg = #{errorMsg},
|
||||
update_by = #{updateBy}
|
||||
update_by = #{updateBy},
|
||||
update_time = #{updateTime}
|
||||
</insert>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue