新版
This commit is contained in:
@ -13,7 +13,7 @@ import java.util.List;
|
||||
public interface CarteenApi {
|
||||
|
||||
/**
|
||||
* 获得门店信息
|
||||
* 根据菜品Id获取门店信息
|
||||
*/
|
||||
public CarteenRespDto getCarteen(Long id);
|
||||
/**
|
||||
|
@ -190,4 +190,6 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode DEVICE_MONEY_NOT_EXISTS = new ErrorCode(1_002_038_002, "门店设备流水不存在");
|
||||
// ========== 门店 设备日流水 1_002_039_002 ==========
|
||||
ErrorCode MATERIAL_NOT_EXISTS = new ErrorCode(1_002_039_002, "门店材料库存不存在");
|
||||
|
||||
ErrorCode FACE_DEVICE_INFO_NOT_EXISTS = new ErrorCode(1_002_040_002, "人脸设备信息关联门店不存在");
|
||||
}
|
||||
|
@ -0,0 +1,98 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.facedeviceinfo;
|
||||
|
||||
import cn.iocoder.yudao.module.system.controller.admin.facedeviceinfo.vo.FaceDeviceInfoPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.facedeviceinfo.vo.FaceDeviceInfoRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.facedeviceinfo.vo.FaceDeviceInfoSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.facedeviceinfo.FaceDeviceInfoDO;
|
||||
import cn.iocoder.yudao.module.system.service.facedeviceinfo.FaceDeviceInfoService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
|
||||
|
||||
@Tag(name = "管理后台 - 人脸设备信息关联门店")
|
||||
@RestController
|
||||
@RequestMapping("/t/face-device-info")
|
||||
@Validated
|
||||
public class FaceDeviceInfoController {
|
||||
|
||||
@Resource
|
||||
private FaceDeviceInfoService faceDeviceInfoService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建人脸设备信息关联门店")
|
||||
@PreAuthorize("@ss.hasPermission('t:face-device-info:create')")
|
||||
public CommonResult<Long> createFaceDeviceInfo(@Valid @RequestBody FaceDeviceInfoSaveReqVO createReqVO) {
|
||||
return success(faceDeviceInfoService.createFaceDeviceInfo(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新人脸设备信息关联门店")
|
||||
@PreAuthorize("@ss.hasPermission('t:face-device-info:update')")
|
||||
public CommonResult<Boolean> updateFaceDeviceInfo(@Valid @RequestBody FaceDeviceInfoSaveReqVO updateReqVO) {
|
||||
faceDeviceInfoService.updateFaceDeviceInfo(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除人脸设备信息关联门店")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('t:face-device-info:delete')")
|
||||
public CommonResult<Boolean> deleteFaceDeviceInfo(@RequestParam("id") Long id) {
|
||||
faceDeviceInfoService.deleteFaceDeviceInfo(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得人脸设备信息关联门店")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('t:face-device-info:query')")
|
||||
public CommonResult<FaceDeviceInfoRespVO> getFaceDeviceInfo(@RequestParam("id") Long id) {
|
||||
FaceDeviceInfoDO faceDeviceInfo = faceDeviceInfoService.getFaceDeviceInfo(id);
|
||||
return success(BeanUtils.toBean(faceDeviceInfo, FaceDeviceInfoRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得人脸设备信息关联门店分页")
|
||||
@PreAuthorize("@ss.hasPermission('t:face-device-info:query')")
|
||||
public CommonResult<PageResult<FaceDeviceInfoRespVO>> getFaceDeviceInfoPage(@Valid FaceDeviceInfoPageReqVO pageReqVO) {
|
||||
PageResult<FaceDeviceInfoDO> pageResult = faceDeviceInfoService.getFaceDeviceInfoPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, FaceDeviceInfoRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出人脸设备信息关联门店 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('t:face-device-info:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportFaceDeviceInfoExcel(@Valid FaceDeviceInfoPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<FaceDeviceInfoDO> list = faceDeviceInfoService.getFaceDeviceInfoPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "人脸设备信息关联门店.xls", "数据", FaceDeviceInfoRespVO.class,
|
||||
BeanUtils.toBean(list, FaceDeviceInfoRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.facedeviceinfo.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 人脸设备信息关联门店分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class FaceDeviceInfoPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "设备mac码")
|
||||
private String mac;
|
||||
|
||||
@Schema(description = "门店编号", example = "29678")
|
||||
private Long carteenId;
|
||||
|
||||
@Schema(description = "设备名称", example = "芋艿")
|
||||
private String deviceName;
|
||||
|
||||
@Schema(description = "门店名称", example = "芋艿")
|
||||
private String carteenName;
|
||||
|
||||
@Schema(description = "激活码")
|
||||
private String activationCode;
|
||||
|
||||
@Schema(description = "设备在线")
|
||||
private String alive;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.facedeviceinfo.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 人脸设备信息关联门店 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class FaceDeviceInfoRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30094")
|
||||
@ExcelProperty("编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "设备mac码")
|
||||
@ExcelProperty("设备mac码")
|
||||
private String mac;
|
||||
|
||||
@Schema(description = "门店编号", example = "29678")
|
||||
@ExcelProperty("门店编号")
|
||||
private Long carteenId;
|
||||
|
||||
@Schema(description = "设备名称", example = "芋艿")
|
||||
@ExcelProperty("设备名称")
|
||||
private String deviceName;
|
||||
|
||||
@Schema(description = "门店名称", example = "芋艿")
|
||||
@ExcelProperty("门店名称")
|
||||
private String carteenName;
|
||||
|
||||
@Schema(description = "激活码")
|
||||
@ExcelProperty("激活码")
|
||||
private String activationCode;
|
||||
|
||||
@Schema(description = "设备在线")
|
||||
@ExcelProperty("设备在线")
|
||||
private String alive;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.facedeviceinfo.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 人脸设备信息关联门店新增/修改 Request VO")
|
||||
@Data
|
||||
public class FaceDeviceInfoSaveReqVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30094")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "设备mac码")
|
||||
private String mac;
|
||||
|
||||
@Schema(description = "门店编号", example = "29678")
|
||||
private Long carteenId;
|
||||
|
||||
@Schema(description = "设备名称", example = "芋艿")
|
||||
private String deviceName;
|
||||
|
||||
@Schema(description = "门店名称", example = "芋艿")
|
||||
private String carteenName;
|
||||
|
||||
@Schema(description = "激活码")
|
||||
private String activationCode;
|
||||
|
||||
@Schema(description = "设备在线")
|
||||
private String alive;
|
||||
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.face;
|
||||
|
||||
import cn.hutool.core.io.file.FileNameUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.system.controller.app.face.dto.QueryDto;
|
||||
import cn.iocoder.yudao.module.system.controller.app.face.dto.SaveDto;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.face.UserFace;
|
||||
import cn.iocoder.yudao.module.system.service.face.FaceService;
|
||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/app/face")
|
||||
@CrossOrigin
|
||||
@Slf4j
|
||||
public class FaceController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private FaceService faceService;
|
||||
|
||||
|
||||
|
||||
@PostMapping("/register")
|
||||
public CommonResult<String> faceAdd(SaveDto saveDto) {
|
||||
log.info("添加人脸特征值到数据库");
|
||||
// 生成雪花id
|
||||
long nextId = IdUtil.getSnowflake().nextId();
|
||||
CommonResult<String> httpResult = CommonResult.success("成功");
|
||||
MultipartFile file = saveDto.getFile();
|
||||
if (file.isEmpty()) {
|
||||
httpResult.setMsg("文件为空");
|
||||
return httpResult;
|
||||
}
|
||||
//获取用户信息
|
||||
Map<String, String> memberUserById = faceService.getMemberUserById(saveDto.getUserId());
|
||||
saveDto.setName(memberUserById.get("nickname"));
|
||||
saveDto.setPhone(memberUserById.get("mobile"));
|
||||
String imagePath = saveFile(file, saveDto.getUserId());
|
||||
// 随机生成一个字符串作为用户ID(测试、实际中禁用)
|
||||
UserFace userById = faceService.getUserById(saveDto.getUserId());
|
||||
if (ObjectUtils.isEmpty(userById)) {
|
||||
UserFace user = new UserFace(nextId, saveDto.getUserId(), saveDto.getPhone(), saveDto.getName(), imagePath);
|
||||
faceService.getBaseMapper().insert(user);
|
||||
// WebServerEndpoint.sendMessage(JSONUtil.toJsonStr(user));
|
||||
} else {
|
||||
nextId = userById.getUserId();
|
||||
userById.setUrl(imagePath);
|
||||
faceService.getBaseMapper().updateById(userById);
|
||||
}
|
||||
|
||||
httpResult.setData(String.valueOf(nextId));
|
||||
return httpResult;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/getAll")
|
||||
public CommonResult<Page<UserFace>> getAll(QueryDto dto) {
|
||||
return CommonResult.success(faceService.getList(dto));
|
||||
}
|
||||
|
||||
|
||||
public String saveFile(MultipartFile file, Long userId) {
|
||||
try {
|
||||
String uploadDirPath = "facedata/";
|
||||
|
||||
// 创建上传文件目录
|
||||
File uploadDir = new File(uploadDirPath);
|
||||
if (!uploadDir.exists()) {
|
||||
uploadDir.mkdir();
|
||||
}
|
||||
String suffix = FileNameUtil.getSuffix(file.getOriginalFilename());
|
||||
String imagePath = uploadDirPath + userId + "." + suffix;
|
||||
// 获取文件字节并保存到指定路径
|
||||
byte[] bytes = file.getBytes();
|
||||
Path path = Paths.get(imagePath);
|
||||
Files.write(path, bytes);
|
||||
return imagePath;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.face.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class QueryDto {
|
||||
private Integer pageNum;
|
||||
private Integer pageSize;
|
||||
private String phone;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.face.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Data
|
||||
public class SaveDto {
|
||||
private String name;
|
||||
private MultipartFile file;
|
||||
private Long userId;
|
||||
private String phone;
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package cn.iocoder.yudao.module.system.controller.app.facedeviceinfo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.facedeviceinfo.vo.FaceDeviceInfoPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.facedeviceinfo.vo.FaceDeviceInfoRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.facedeviceinfo.vo.FaceDeviceInfoSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.facedeviceinfo.FaceDeviceInfoDO;
|
||||
import cn.iocoder.yudao.module.system.service.facedeviceinfo.FaceDeviceInfoService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
|
||||
|
||||
@Tag(name = "管理后台 - 人脸设备信息关联门店")
|
||||
@RestController
|
||||
@RequestMapping("/t/face-device-info")
|
||||
@Validated
|
||||
public class AppFaceDeviceInfoController {
|
||||
|
||||
@Resource
|
||||
private FaceDeviceInfoService faceDeviceInfoService;
|
||||
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得人脸设备信息关联门店")
|
||||
@Parameter(name = "mac", description = "设备mac码", required = true, example = "1024")
|
||||
public CommonResult<FaceDeviceInfoRespVO> getFaceDeviceInfo(@RequestParam("mac") String mac) {
|
||||
FaceDeviceInfoDO faceDeviceInfo = faceDeviceInfoService.getInfo(mac);
|
||||
return success(BeanUtils.toBean(faceDeviceInfo, FaceDeviceInfoRespVO.class));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package cn.iocoder.yudao.module.system.dal.dataobject.face;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("user_face")
|
||||
public class UserFace {
|
||||
@TableId
|
||||
private Long userId;
|
||||
private byte[] featureValue;
|
||||
private String url;
|
||||
private Long sysUserId;
|
||||
private String name;
|
||||
private String phone;
|
||||
private LocalDateTime createTime;
|
||||
|
||||
public UserFace(Long userId, Long sysUserId, String phone, String name, String url) {
|
||||
this.phone = phone;
|
||||
this.name = name;
|
||||
this.sysUserId = sysUserId;
|
||||
this.userId = userId;
|
||||
this.url = url;
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.system.dal.dataobject.facedeviceinfo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 人脸设备信息关联门店 DO
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@TableName("t_face_device_info")
|
||||
@KeySequence("t_face_device_info_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class FaceDeviceInfoDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 设备mac码
|
||||
*/
|
||||
private String mac;
|
||||
/**
|
||||
* 门店编号
|
||||
*/
|
||||
private Long carteenId;
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String deviceName;
|
||||
/**
|
||||
* 门店名称
|
||||
*/
|
||||
private String carteenName;
|
||||
/**
|
||||
* 激活码
|
||||
*/
|
||||
private String activationCode;
|
||||
/**
|
||||
* 设备在线
|
||||
*/
|
||||
private String alive;
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.system.dal.mysql.face;
|
||||
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.face.UserFace;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface FaceMapper extends BaseMapper<UserFace>{
|
||||
|
||||
@Insert("insert into user_face (user_id,feature_value,url,sys_user_id) values (#{userId},#{featureValue},#{url},#{sysUserId})")
|
||||
Boolean add(UserFace user);
|
||||
|
||||
@Select("select * from user_face")
|
||||
List<UserFace> getAllUser();
|
||||
|
||||
|
||||
//根据id查询用户
|
||||
@Select("select * from user_face where sys_user_id = #{userId}")
|
||||
UserFace getUserById(Long userId);
|
||||
|
||||
|
||||
@Select("select nickname,mobile from member_user where id = #{userId}")
|
||||
Map<String,String> getMemberUserById(Long userId);
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.system.dal.mysql.facedeviceinfo;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.facedeviceinfo.vo.FaceDeviceInfoPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.facedeviceinfo.FaceDeviceInfoDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
/**
|
||||
* 人脸设备信息关联门店 Mapper
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@Mapper
|
||||
public interface FaceDeviceInfoMapper extends BaseMapperX<FaceDeviceInfoDO> {
|
||||
|
||||
default PageResult<FaceDeviceInfoDO> selectPage(FaceDeviceInfoPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<FaceDeviceInfoDO>()
|
||||
.eqIfPresent(FaceDeviceInfoDO::getMac, reqVO.getMac())
|
||||
.eqIfPresent(FaceDeviceInfoDO::getCarteenId, reqVO.getCarteenId())
|
||||
.likeIfPresent(FaceDeviceInfoDO::getDeviceName, reqVO.getDeviceName())
|
||||
.likeIfPresent(FaceDeviceInfoDO::getCarteenName, reqVO.getCarteenName())
|
||||
.eqIfPresent(FaceDeviceInfoDO::getActivationCode, reqVO.getActivationCode())
|
||||
.eqIfPresent(FaceDeviceInfoDO::getAlive, reqVO.getAlive())
|
||||
.betweenIfPresent(FaceDeviceInfoDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(FaceDeviceInfoDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -6,8 +6,11 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.deviceinfo.vo.DeviceInfoPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.deviceinfo.vo.DeviceInfoSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.deviceInfo.DeviceInfoDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.facedeviceinfo.FaceDeviceInfoDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.deviceInfo.DeviceInfoMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.facedeviceinfo.FaceDeviceInfoMapper;
|
||||
import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants;
|
||||
import cn.iocoder.yudao.module.system.service.facedeviceinfo.FaceDeviceInfoService;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
@ -40,6 +43,9 @@ public class DeviceInfoServiceImpl implements DeviceInfoService {
|
||||
@Resource
|
||||
private HttpServletRequest httpServletRequest;
|
||||
|
||||
@Resource
|
||||
private FaceDeviceInfoMapper faceDeviceInfoMapper;
|
||||
|
||||
@Override
|
||||
public Long createDeviceInfo(DeviceInfoSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
@ -89,6 +95,9 @@ public class DeviceInfoServiceImpl implements DeviceInfoService {
|
||||
deviceInfoMapper.update(new DeviceInfoDO(),new LambdaUpdateWrapper<DeviceInfoDO>()
|
||||
.eq(DeviceInfoDO::getDeviceIp,deviceSn)
|
||||
.set(DeviceInfoDO::getAlive,"1"));
|
||||
faceDeviceInfoMapper.update(new FaceDeviceInfoDO(),new LambdaUpdateWrapper<FaceDeviceInfoDO>()
|
||||
.eq(FaceDeviceInfoDO::getMac,deviceSn)
|
||||
.set(FaceDeviceInfoDO::getAlive,"1"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -112,7 +121,28 @@ public class DeviceInfoServiceImpl implements DeviceInfoService {
|
||||
.set(DeviceInfoDO::getAlive,"0")
|
||||
.in(DeviceInfoDO::getDeviceIp,updateList));
|
||||
}
|
||||
return updateList.size();
|
||||
|
||||
List<String> upList = new ArrayList<>();
|
||||
List<FaceDeviceInfoDO> faceDeviceInfoDOS = faceDeviceInfoMapper.selectList();
|
||||
List<String> macList = faceDeviceInfoDOS.stream().map(FaceDeviceInfoDO::getMac).collect(Collectors.toList());
|
||||
for (String deviceSn : macList){
|
||||
String time = RedisTemplate.opsForValue().get(deviceSn);
|
||||
if(StringUtils.isBlank(time)){
|
||||
upList.add(deviceSn);
|
||||
continue;
|
||||
}
|
||||
if(System.currentTimeMillis()-Long.valueOf(time)>120000){
|
||||
upList.add(deviceSn);
|
||||
}
|
||||
}
|
||||
|
||||
if(CollectionUtil.isNotEmpty(upList)){
|
||||
faceDeviceInfoMapper.update(new FaceDeviceInfoDO(),new LambdaUpdateWrapper<FaceDeviceInfoDO>()
|
||||
.set(FaceDeviceInfoDO::getAlive,"0")
|
||||
.in(FaceDeviceInfoDO::getMac,upList));
|
||||
}
|
||||
|
||||
return updateList.size()+upList.size();
|
||||
}
|
||||
|
||||
public String getHearder(){
|
||||
|
@ -0,0 +1,49 @@
|
||||
package cn.iocoder.yudao.module.system.service.face;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.module.system.controller.app.face.dto.QueryDto;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.face.UserFace;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.face.FaceMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class FaceService extends ServiceImpl<FaceMapper, UserFace> implements IService<UserFace> {
|
||||
|
||||
@Autowired
|
||||
private FaceMapper mapper;
|
||||
|
||||
//注册人脸
|
||||
public void faceAdd(UserFace user) {
|
||||
mapper.add(user);
|
||||
}
|
||||
//查找人脸
|
||||
public List<UserFace> getAllUserFace() {
|
||||
return mapper.getAllUser();
|
||||
}
|
||||
|
||||
public UserFace getUserById(Long userId) {
|
||||
return mapper.getUserById(userId);
|
||||
}
|
||||
|
||||
public Page<UserFace> getList(QueryDto dto) {
|
||||
Page<UserFace> page = new Page<>(dto.getPageNum(), dto.getPageSize());
|
||||
LambdaQueryWrapper<UserFace> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.like(StrUtil.isNotBlank(dto.getPhone()), UserFace::getPhone, dto.getPhone());
|
||||
wrapper.orderByDesc(UserFace::getCreateTime);
|
||||
return mapper.selectPage(page, wrapper);
|
||||
}
|
||||
|
||||
public Map<String,String> getMemberUserById(Long id) {
|
||||
return mapper.getMemberUserById(id);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package cn.iocoder.yudao.module.system.service.facedeviceinfo;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.facedeviceinfo.vo.FaceDeviceInfoPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.facedeviceinfo.vo.FaceDeviceInfoSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.facedeviceinfo.FaceDeviceInfoDO;
|
||||
|
||||
/**
|
||||
* 人脸设备信息关联门店 Service 接口
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
public interface FaceDeviceInfoService {
|
||||
|
||||
/**
|
||||
* 创建人脸设备信息关联门店
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createFaceDeviceInfo(@Valid FaceDeviceInfoSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新人脸设备信息关联门店
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateFaceDeviceInfo(@Valid FaceDeviceInfoSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除人脸设备信息关联门店
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteFaceDeviceInfo(Long id);
|
||||
|
||||
/**
|
||||
* 获得人脸设备信息关联门店
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 人脸设备信息关联门店
|
||||
*/
|
||||
FaceDeviceInfoDO getFaceDeviceInfo(Long id);
|
||||
|
||||
/**
|
||||
* 获得人脸设备信息关联门店分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 人脸设备信息关联门店分页
|
||||
*/
|
||||
PageResult<FaceDeviceInfoDO> getFaceDeviceInfoPage(FaceDeviceInfoPageReqVO pageReqVO);
|
||||
|
||||
FaceDeviceInfoDO getInfo(String mac);
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
package cn.iocoder.yudao.module.system.service.facedeviceinfo;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.facedeviceinfo.vo.FaceDeviceInfoPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.facedeviceinfo.vo.FaceDeviceInfoSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.facedeviceinfo.FaceDeviceInfoDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.carteen.CarteenMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.facedeviceinfo.FaceDeviceInfoMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.FACE_DEVICE_INFO_NOT_EXISTS;
|
||||
|
||||
|
||||
/**
|
||||
* 人脸设备信息关联门店 Service 实现类
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class FaceDeviceInfoServiceImpl implements FaceDeviceInfoService {
|
||||
|
||||
@Resource
|
||||
private FaceDeviceInfoMapper faceDeviceInfoMapper;
|
||||
|
||||
@Resource
|
||||
private CarteenMapper carteenMapper;
|
||||
|
||||
@Override
|
||||
public Long createFaceDeviceInfo(FaceDeviceInfoSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
FaceDeviceInfoDO faceDeviceInfo = BeanUtils.toBean(createReqVO, FaceDeviceInfoDO.class);
|
||||
faceDeviceInfoMapper.insert(faceDeviceInfo);
|
||||
// 返回
|
||||
return faceDeviceInfo.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFaceDeviceInfo(FaceDeviceInfoSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateFaceDeviceInfoExists(updateReqVO.getId());
|
||||
// 更新
|
||||
FaceDeviceInfoDO updateObj = BeanUtils.toBean(updateReqVO, FaceDeviceInfoDO.class);
|
||||
faceDeviceInfoMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteFaceDeviceInfo(Long id) {
|
||||
// 校验存在
|
||||
validateFaceDeviceInfoExists(id);
|
||||
// 删除
|
||||
faceDeviceInfoMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateFaceDeviceInfoExists(Long id) {
|
||||
if (faceDeviceInfoMapper.selectById(id) == null) {
|
||||
throw exception(FACE_DEVICE_INFO_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaceDeviceInfoDO getFaceDeviceInfo(Long id) {
|
||||
return faceDeviceInfoMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<FaceDeviceInfoDO> getFaceDeviceInfoPage(FaceDeviceInfoPageReqVO pageReqVO) {
|
||||
PageResult<FaceDeviceInfoDO> faceDeviceInfoDOPageResult = faceDeviceInfoMapper.selectPage(pageReqVO);
|
||||
List<FaceDeviceInfoDO> list = faceDeviceInfoDOPageResult.getList();
|
||||
if (CollectionUtil.isNotEmpty(list)){
|
||||
list.forEach(vo ->{
|
||||
vo.setCarteenName(carteenMapper.selectById(vo.getCarteenId()).getStoresName());
|
||||
});
|
||||
}
|
||||
return faceDeviceInfoDOPageResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaceDeviceInfoDO getInfo(String mac) {
|
||||
LambdaQueryWrapper<FaceDeviceInfoDO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(FaceDeviceInfoDO::getMac, mac);
|
||||
FaceDeviceInfoDO faceDeviceInfoDO = faceDeviceInfoMapper.selectOne(wrapper);
|
||||
faceDeviceInfoDO.setCarteenName(carteenMapper.selectById(faceDeviceInfoDO.getCarteenId()).getStoresName());
|
||||
return faceDeviceInfoDO;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user