根据mac获取门店
This commit is contained in:
@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.member.controller.app.diningplates.vo.AppUserInfo
|
||||
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserInfoCardVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.diningplates.DiningPlatesDO;
|
||||
import cn.iocoder.yudao.module.member.service.diningplates.DiningPlatesService;
|
||||
import cn.iocoder.yudao.module.system.api.deviceInfo.DeviceInfoApi;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -18,9 +19,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "用户 App - 餐盘")
|
||||
@ -32,6 +35,11 @@ public class AppDiningPlatesController {
|
||||
@Resource
|
||||
private DiningPlatesService diningPlatesService;
|
||||
|
||||
@Resource
|
||||
private HttpServletRequest httpServletRequest;
|
||||
|
||||
@Resource
|
||||
private DeviceInfoApi deviceInfoApi;
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得餐盘列表")
|
||||
@ -55,12 +63,14 @@ public class AppDiningPlatesController {
|
||||
@GetMapping("/checkBind")
|
||||
@Operation(summary = "验证餐盘绑定")
|
||||
public CommonResult<AppUserInfoCardVO> checkBind(String diningPlatesNum,Long storeId) {
|
||||
storeId = getCarteen();
|
||||
return success(diningPlatesService.appCheckBind(diningPlatesNum,storeId));
|
||||
}
|
||||
|
||||
@GetMapping("/unbind")
|
||||
@Operation(summary = "餐盘解绑")
|
||||
public CommonResult<String> unbind(String diningPlatesNum,Long storeId) {
|
||||
storeId = getCarteen();
|
||||
diningPlatesService.unbind(diningPlatesNum,storeId);
|
||||
return success(diningPlatesNum);
|
||||
}
|
||||
@ -68,6 +78,7 @@ public class AppDiningPlatesController {
|
||||
@GetMapping("/getUserAndDish")
|
||||
@Operation(summary = "根据餐盘号获取当前余额")
|
||||
public CommonResult<AppUserInfo> getMoney(String cId, Long dishesId,Long storeId) {
|
||||
storeId = getCarteen();
|
||||
return success(diningPlatesService.getMoney(cId,dishesId,storeId));
|
||||
}
|
||||
|
||||
@ -80,6 +91,7 @@ public class AppDiningPlatesController {
|
||||
@GetMapping("/checkBindAndUnBind")
|
||||
@Operation(summary = "餐盘解绑")
|
||||
public CommonResult<String> checkBindAndUnBind(String diningPlatesNum,Long storeId) {
|
||||
storeId = getCarteen();
|
||||
String b = diningPlatesService.checkBindAndUnBind(diningPlatesNum, storeId);
|
||||
CommonResult<String> result = new CommonResult<>();
|
||||
result.setCode(200);
|
||||
@ -95,4 +107,16 @@ public class AppDiningPlatesController {
|
||||
public CommonResult<Long> createDiningPlates(@Valid @RequestBody DiningPlatesSaveReqVO createReqVO) {
|
||||
return success(diningPlatesService.createDiningPlates(createReqVO));
|
||||
}
|
||||
|
||||
|
||||
public Long getCarteen() {
|
||||
try {
|
||||
String authorization = httpServletRequest.getHeader("Authorization");
|
||||
Long carteen = deviceInfoApi.getCarteen(authorization);
|
||||
|
||||
return carteen;
|
||||
} catch (Exception e) {
|
||||
throw exception(2000_10_001, "无法获取设备编码");
|
||||
}
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ import cn.iocoder.yudao.module.member.controller.app.orderdetail.vo.AppOrderDeta
|
||||
import cn.iocoder.yudao.module.member.controller.app.orderdetail.vo.AppOrderDetailSaveReqVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.orderdetail.OrderDetailDO;
|
||||
import cn.iocoder.yudao.module.member.service.orderdetail.OrderDetailService;
|
||||
import cn.iocoder.yudao.module.system.api.deviceInfo.DeviceInfoApi;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -26,11 +27,13 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
@ -43,9 +46,16 @@ public class AppOrderDetailController {
|
||||
@Resource
|
||||
private OrderDetailService orderDetailService;
|
||||
|
||||
@Resource
|
||||
private HttpServletRequest httpServletRequest;
|
||||
|
||||
@Resource
|
||||
private DeviceInfoApi deviceInfoApi;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建订单明细")
|
||||
public CommonResult<Long> createOrderDetail(@Valid @RequestBody AppOrderDetailSaveReqVO createReqVO) {
|
||||
createReqVO.setStoreId(getCarteen());
|
||||
return success(orderDetailService.createOrderDetail(createReqVO));
|
||||
}
|
||||
|
||||
@ -95,4 +105,14 @@ public class AppOrderDetailController {
|
||||
BeanUtils.toBean(list, OrderDetailRespVO.class));
|
||||
}
|
||||
|
||||
public Long getCarteen() {
|
||||
try {
|
||||
String authorization = httpServletRequest.getHeader("Authorization");
|
||||
Long carteen = deviceInfoApi.getCarteen(authorization);
|
||||
|
||||
return carteen;
|
||||
} catch (Exception e) {
|
||||
throw exception(2000_10_001, "无法获取设备编码");
|
||||
}
|
||||
}
|
||||
}
|
@ -21,4 +21,6 @@ public interface DeviceInfoApi {
|
||||
DeviceInfoDto getDevice(String deviceIp);
|
||||
|
||||
List<DeviceInfoDto> getDevice();
|
||||
|
||||
Long getCarteen(String mac);
|
||||
}
|
||||
|
@ -1,10 +1,14 @@
|
||||
package cn.iocoder.yudao.module.system.api.deviceInfo;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.system.api.deviceInfo.dto.DeviceInfoDto;
|
||||
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 com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -18,6 +22,10 @@ import java.util.List;
|
||||
public class DeviceInfoApiImpl implements DeviceInfoApi {
|
||||
@Resource
|
||||
private DeviceInfoMapper deviceInfoMapper;
|
||||
|
||||
@Resource
|
||||
private FaceDeviceInfoMapper faceDeviceInfoMapper;
|
||||
|
||||
@Override
|
||||
public List<DeviceInfoDto> getDeviceInfoList(Long carteenId) {
|
||||
return BeanUtils.toBean(deviceInfoMapper.selectList(new LambdaQueryWrapperX<DeviceInfoDO>()
|
||||
@ -52,4 +60,21 @@ public class DeviceInfoApiImpl implements DeviceInfoApi {
|
||||
List<DeviceInfoDO> deviceInfoDOS = deviceInfoMapper.selectList();
|
||||
return BeanUtils.toBean(deviceInfoDOS,DeviceInfoDto.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getCarteen(String mac) {
|
||||
DeviceInfoDO deviceInfoDO = deviceInfoMapper.selectOne(new LambdaQueryWrapper<DeviceInfoDO>()
|
||||
.eq(DeviceInfoDO::getDeviceIp, mac)
|
||||
.last("limit 1"));
|
||||
if(ObjectUtil.isNotEmpty(deviceInfoDO)){
|
||||
return deviceInfoDO.getCarteenId();
|
||||
}
|
||||
FaceDeviceInfoDO faceDeviceInfoDO = faceDeviceInfoMapper.selectOne(new LambdaQueryWrapper<FaceDeviceInfoDO>()
|
||||
.eq(FaceDeviceInfoDO::getMac, mac)
|
||||
.last("limit 1"));
|
||||
if(ObjectUtil.isNotEmpty(faceDeviceInfoDO)){
|
||||
return faceDeviceInfoDO.getCarteenId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -110,6 +110,9 @@ public class DeviceInfoServiceImpl implements DeviceInfoService {
|
||||
List<DeviceInfoDO> deviceInfoDOS = deviceInfoMapper.selectList();
|
||||
List<String> devuceList = deviceInfoDOS.stream().map(DeviceInfoDO::getDeviceIp).collect(Collectors.toList());
|
||||
for (String deviceSn : devuceList){
|
||||
if(StringUtils.isBlank(deviceSn)){
|
||||
continue;
|
||||
}
|
||||
String time = RedisTemplate.opsForValue().get(deviceSn);
|
||||
if(StringUtils.isBlank(time)){
|
||||
updateList.add(deviceSn);
|
||||
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.service.devuce;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
@ -21,6 +22,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 com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -168,7 +170,14 @@ public class DevuceServiceImpl implements DevuceService {
|
||||
// .eq(DishesDO::getCarteenId,carteenId)
|
||||
// .eq(DishesDO::getDishecType,dishecType));
|
||||
// }else{
|
||||
return dishesMapper.selectList(new LambdaQueryWrapperX<DishesDO>()
|
||||
String mac = this.getHearder();
|
||||
DeviceInfoDO deviceInfoDO = deviceInfoMapper.selectOne(new LambdaQueryWrapper<DeviceInfoDO>()
|
||||
.eq(DeviceInfoDO::getDeviceIp, mac)
|
||||
.last("limit 1"));
|
||||
if(ObjectUtil.isNotEmpty(deviceInfoDO)){
|
||||
carteenId = deviceInfoDO.getCarteenId();
|
||||
}
|
||||
return dishesMapper.selectList(new LambdaQueryWrapperX<DishesDO>()
|
||||
.eq(DishesDO::getCarteenId,carteenId)
|
||||
.eq(DishesDO::getDishecType,dishecType));
|
||||
// }
|
||||
|
Reference in New Issue
Block a user