This commit is contained in:
zt
2025-01-02 09:28:49 +08:00
parent 5e247cb63a
commit 6e9c0c21bc
39 changed files with 510 additions and 92 deletions

View File

@ -0,0 +1,9 @@
package cn.iocoder.yudao.module.system.api.face;
import cn.iocoder.yudao.module.system.api.face.dto.UserJsonDto;
public interface FaceApi {
Long addFace(UserJsonDto userJson);
}

View File

@ -0,0 +1,16 @@
package cn.iocoder.yudao.module.system.api.face.dto;
import lombok.Data;
import lombok.ToString;
@Data
@ToString
public class UserJsonDto {
private String userNickname;
private String phoneNumber;
private String url;
private Long userId;
private Long carteenId;
}

View File

@ -0,0 +1,42 @@
package cn.iocoder.yudao.module.system.api.face;
import cn.hutool.core.util.IdUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.system.api.face.dto.UserJsonDto;
import cn.iocoder.yudao.module.system.dal.dataobject.face.UserFace;
import cn.iocoder.yudao.module.system.service.face.FaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
import java.util.Map;
@Service
public class FaceApiImpl implements FaceApi {
@Autowired
private FaceService faceService;
@Override
public Long addFace(UserJsonDto userJson) {
// 生成雪花id
long nextId = IdUtil.getSnowflake().nextId();
CommonResult<Map<String,String>> httpResult = new CommonResult<>();
// 随机生成一个字符串作为用户ID(测试、实际中禁用)
UserFace userById = faceService.getUserById(userJson.getUserId());
if (ObjectUtils.isEmpty(userById)) {
UserFace user = new UserFace(nextId, userJson.getUserId(), userJson.getPhoneNumber(), userJson.getUserNickname(), userJson.getUrl());
user.setCarteenId(userJson.getCarteenId());
faceService.getBaseMapper().insert(user);
} else {
nextId = userById.getUserId();
userById.setUrl(userJson.getUrl());
faceService.getBaseMapper().updateById(userById);
}
return nextId;
}
}

View File

@ -130,6 +130,14 @@ public class AppDevuceController {
public CommonResult<Long> getCarteenId() {
return success(devuceService.getCarteenIdByIp());
}
@GetMapping("/carteenNew")
@Operation(summary = "根据ip获取门店id")
public CommonResult<Map<String,Object>> getCarteenIdNew() {
return success(devuceService.getCarteenIdByIpNew());
}
@GetMapping("/nutrition")
@Operation(summary = "获取菜品营养成分")
public CommonResult<List<Map>> getDishesNutrition(@RequestParam("dishesId") Long dishesId,@RequestParam(value = "cId",required = false) String cId) {
@ -150,7 +158,6 @@ public class AppDevuceController {
return success(true);
}
@GetMapping("/alive")
@Operation(summary = "在线检测")
public void alive() {

View File

@ -77,6 +77,7 @@ public class FaceController {
@GetMapping("/getAll")
public CommonResult<Page<UserFace>> getAll(QueryDto dto) {
return CommonResult.success(faceService.getList(dto));
}

View File

@ -21,6 +21,7 @@ public class UserFace {
private String name;
private String phone;
private LocalDateTime createTime;
private Long carteenId;
public UserFace(Long userId, Long sysUserId, String phone, String name, String url) {
this.phone = phone;

View File

@ -8,13 +8,16 @@ import cn.iocoder.yudao.module.system.controller.admin.deviceinfo.vo.DeviceInfoP
import cn.iocoder.yudao.module.system.controller.admin.deviceinfo.vo.DeviceInfoSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.cashregisterinfo.CashRegisterInfoDO;
import cn.iocoder.yudao.module.system.dal.dataobject.deviceInfo.DeviceInfoDO;
import cn.iocoder.yudao.module.system.dal.dataobject.devuce.DevuceDO;
import cn.iocoder.yudao.module.system.dal.dataobject.facedeviceinfo.FaceDeviceInfoDO;
import cn.iocoder.yudao.module.system.dal.mysql.cashregisterinfo.CashRegisterInfoMapper;
import cn.iocoder.yudao.module.system.dal.mysql.deviceInfo.DeviceInfoMapper;
import cn.iocoder.yudao.module.system.dal.mysql.devuce.DevuceMapper;
import cn.iocoder.yudao.module.system.dal.mysql.facedeviceinfo.FaceDeviceInfoMapper;
import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
@ -52,6 +55,9 @@ public class DeviceInfoServiceImpl implements DeviceInfoService {
@Resource
private CashRegisterInfoMapper cashRegisterInfoMapper;
@Resource
private DevuceMapper devuceMapper;
@Override
public Long createDeviceInfo(DeviceInfoSaveReqVO createReqVO) {
// 插入
@ -78,6 +84,9 @@ public class DeviceInfoServiceImpl implements DeviceInfoService {
// 更新
DeviceInfoDO updateObj = BeanUtils.toBean(updateReqVO, DeviceInfoDO.class);
deviceInfoMapper.updateById(updateObj);
//清空设备绑定菜品
devuceMapper.update(Wrappers.<DevuceDO>lambdaUpdate().eq(DevuceDO::getDeviceSn,updateObj.getDeviceIp())
.eq(DevuceDO::getBind,true).set(DevuceDO::getDishesId,null));
}
@Override

View File

@ -58,39 +58,50 @@ public interface DevuceService {
* @return 设备分页
*/
PageResult<DevuceDO> getDevucePage(DevucePageReqVO pageReqVO);
/**
* @return
* @Description: 设备绑定菜品,或计算菜品重量与剩余重量
* @Author: qjq
* @Date: 2024/4/10 下午1:40
* @return
* @Date: 2024/4/10 下午1:40
*/
DishesDO getDevuceList();
List<DishesDO> getDishesList(Long carteenId,Long dishecType,String dishesName);
List<DishesDO> getDishesList(Long carteenId, Long dishecType, String dishesName);
PageResult<DishesDO> getDishesPage(Long carteenId, Long dishecType, String dishesName, Integer pageNo, Integer pageSize);
PageResult<DishesDO> getDishesPage(Long carteenId, Long dishecType, String dishesName,Integer pageNo,Integer pageSize);
/**
* @return
* @Description: 获取菜品分类
* @Author: qjq
* @Date: 2024/4/9 上午10:33
* @return
*/
List<DishesTypeDO> getDishesTypeList(Long carteenId);
/**
* @Description: 根据ip获取门店id
* @Author: qjq
* @Date: 2024/4/10 下午4:28
* @return
*/
Long getCarteenIdByIp();
/**
* @return
* @Description: 根据ip获取门店id
* @Author: qjq
* @Date: 2024/4/10 下午4:28
*/
Long getCarteenIdByIp();
/**
* @return
* @Description: 根据ip获取门店id
* @Author: qjq
* @Date: 2024/4/10 下午4:28
*/
Map<String, Object> getCarteenIdByIpNew();
/**
* @return
* @Description: 获取菜品营养与菜品名称
* @Author: qjq
* @Date: 2024/4/19 下午2:44
* @return
*/
List<Map> getDishesNutrition(Long dishesId,String cId);
List<Map> getDishesNutrition(Long dishesId, String cId);
void updateWeight(DevuceReqVO updateReqVO);

View File

@ -23,6 +23,7 @@ import cn.iocoder.yudao.module.system.dal.mysql.dishes.DishesMapper;
import cn.iocoder.yudao.module.system.dal.mysql.dishesnutrition.DishesNutritionMapper;
import cn.iocoder.yudao.module.system.dal.mysql.dishestype.DishesTypeMapper;
import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants;
import cn.iocoder.yudao.module.system.service.carteen.CarteenService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -63,6 +64,8 @@ public class DevuceServiceImpl implements DevuceService {
private DeviceInfoMapper deviceInfoMapper;
@Resource
private DishesNutritionMapper dishesNutritionMapper;
@Resource
private CarteenService carteenService;
@Override
@ -275,9 +278,6 @@ public class DevuceServiceImpl implements DevuceService {
return maps;
}
/**
* @return
* @Description: 根据ip获取门店id
@ -297,6 +297,29 @@ public class DevuceServiceImpl implements DevuceService {
}
}
/**
* @return
* @Description: 根据ip获取门店id
* @Author: qjq
* @Date: 2024/4/10 下午4:28
*/
@Override
public Map<String, Object> getCarteenIdByIpNew() {
String hearder = this.getHearder();
List<DeviceInfoDO> deviceInfoDOS = deviceInfoMapper.selectList(new LambdaQueryWrapperX<DeviceInfoDO>()
.eq(DeviceInfoDO::getDeviceIp, hearder)
);
if(ObjUtil.isNotEmpty(deviceInfoDOS)){
HashMap<String, Object> map = new HashMap<>();
Long carteenId = deviceInfoDOS.get(0).getCarteenId();
map.put("carteenId",carteenId);
map.put("carteenName",carteenService.getCarteen(carteenId).getStoresName());
return map;
}else{
throw exception(2000_10_002,"无法通IP获取门店");
}
}
@Override
public void updateWeight(DevuceReqVO updateReqVO) {
String hearder = this.getHearder();

View File

@ -4,6 +4,8 @@ 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 cn.iocoder.yudao.module.system.service.deviceinfo.DeviceInfoService;
import cn.iocoder.yudao.module.system.service.facedeviceinfo.FaceDeviceInfoService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
@ -12,6 +14,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@ -20,7 +24,10 @@ public class FaceService extends ServiceImpl<FaceMapper, UserFace> implements IS
@Autowired
private FaceMapper mapper;
@Resource
private HttpServletRequest httpServletRequest;
@Resource
private FaceDeviceInfoService faceDeviceInfoService;
//注册人脸
public void faceAdd(UserFace user) {
mapper.add(user);
@ -35,9 +42,14 @@ public class FaceService extends ServiceImpl<FaceMapper, UserFace> implements IS
}
public Page<UserFace> getList(QueryDto dto) {
String authorization = httpServletRequest.getHeader("Authorization");
Long carteenId = faceDeviceInfoService.getInfo(authorization).getCarteenId();
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.and(w -> w.eq(UserFace::getCarteenId,carteenId)
.or().isNull(UserFace::getCarteenId));
wrapper.orderByDesc(UserFace::getCreateTime);
return mapper.selectPage(page, wrapper);
}