ip获取门店
This commit is contained in:
@ -75,8 +75,8 @@ public class DevuceController {
|
|||||||
}
|
}
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@Operation(summary = "获得绑定的菜品")
|
@Operation(summary = "获得绑定的菜品")
|
||||||
public CommonResult<DishesRespVO> getDevuceList(@RequestParam("sn")String sn){
|
public CommonResult<DishesRespVO> getDevuceList(){
|
||||||
DishesDO devuceList = devuceService.getDevuceList(sn);
|
DishesDO devuceList = devuceService.getDevuceList();
|
||||||
return success(BeanUtils.toBean(devuceList, DishesRespVO.class));
|
return success(BeanUtils.toBean(devuceList, DishesRespVO.class));
|
||||||
}
|
}
|
||||||
@GetMapping("/type")
|
@GetMapping("/type")
|
||||||
@ -104,5 +104,9 @@ public class DevuceController {
|
|||||||
// ExcelUtils.write(response, "设备.xls", "数据", DevuceRespVO.class,
|
// ExcelUtils.write(response, "设备.xls", "数据", DevuceRespVO.class,
|
||||||
// BeanUtils.toBean(list, DevuceRespVO.class));
|
// BeanUtils.toBean(list, DevuceRespVO.class));
|
||||||
// }
|
// }
|
||||||
|
@GetMapping("/carteen")
|
||||||
|
@Operation(summary = "根据ip获取门店id")
|
||||||
|
public CommonResult<Long> getCarteenId() {
|
||||||
|
return success(devuceService.getCarteenIdByIp());
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.dal.dataobject.deviceInfo;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:qjq
|
||||||
|
* @Date:2024/4/10 下午4:37
|
||||||
|
*/
|
||||||
|
@TableName("t_device_info")
|
||||||
|
@KeySequence("t_device_info_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DeviceInfoDO extends BaseDO {
|
||||||
|
/**
|
||||||
|
* 编号
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备sn码
|
||||||
|
*/
|
||||||
|
private String deviceSn;
|
||||||
|
/**
|
||||||
|
* 门店编号
|
||||||
|
*/
|
||||||
|
private Long carteenId;
|
||||||
|
/**
|
||||||
|
* 设备ip
|
||||||
|
*/
|
||||||
|
private String deviceIp;
|
||||||
|
/**
|
||||||
|
* 设备名称
|
||||||
|
*/
|
||||||
|
private String deviceName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 门店名称
|
||||||
|
*/
|
||||||
|
private String carteenName;
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.dal.mysql.deviceInfo;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.deviceInfo.DeviceInfoDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:qjq
|
||||||
|
* @Date:2024/4/10 下午4:37
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface DeviceInfoMapper extends BaseMapperX<DeviceInfoDO> {
|
||||||
|
}
|
@ -60,7 +60,7 @@ public interface DevuceService {
|
|||||||
* @Date: 2024/4/10 下午1:40
|
* @Date: 2024/4/10 下午1:40
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
DishesDO getDevuceList(String sn);
|
DishesDO getDevuceList();
|
||||||
|
|
||||||
List<DishesDO> getDishesList(Long carteenId,Long dishecType);
|
List<DishesDO> getDishesList(Long carteenId,Long dishecType);
|
||||||
/**
|
/**
|
||||||
@ -71,6 +71,11 @@ public interface DevuceService {
|
|||||||
*/
|
*/
|
||||||
List<DishesTypeDO> getDishesTypeList(Long carteenId);
|
List<DishesTypeDO> getDishesTypeList(Long carteenId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 根据ip获取门店id
|
||||||
|
* @Author: qjq
|
||||||
|
* @Date: 2024/4/10 下午4:28
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Long getCarteenIdByIp();
|
||||||
}
|
}
|
@ -6,9 +6,11 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import cn.iocoder.yudao.module.system.controller.app.devuce.vo.DevucePageReqVO;
|
import cn.iocoder.yudao.module.system.controller.app.devuce.vo.DevucePageReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.app.devuce.vo.DevuceSaveReqVO;
|
import cn.iocoder.yudao.module.system.controller.app.devuce.vo.DevuceSaveReqVO;
|
||||||
|
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.devuce.DevuceDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.dishes.DishesDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.dishes.DishesDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.dishestype.DishesTypeDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.dishestype.DishesTypeDO;
|
||||||
|
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.devuce.DevuceMapper;
|
||||||
import cn.iocoder.yudao.module.system.dal.mysql.dishes.DishesMapper;
|
import cn.iocoder.yudao.module.system.dal.mysql.dishes.DishesMapper;
|
||||||
import cn.iocoder.yudao.module.system.dal.mysql.dishestype.DishesTypeMapper;
|
import cn.iocoder.yudao.module.system.dal.mysql.dishestype.DishesTypeMapper;
|
||||||
@ -41,6 +43,8 @@ public class DevuceServiceImpl implements DevuceService {
|
|||||||
private DishesTypeMapper dishesTypeMapper;
|
private DishesTypeMapper dishesTypeMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private HttpServletRequest httpServletRequest;
|
private HttpServletRequest httpServletRequest;
|
||||||
|
@Resource
|
||||||
|
private DeviceInfoMapper deviceInfoMapper;
|
||||||
@Override
|
@Override
|
||||||
public Long createDevuce(DevuceSaveReqVO createReqVO) {
|
public Long createDevuce(DevuceSaveReqVO createReqVO) {
|
||||||
// 插入
|
// 插入
|
||||||
@ -76,16 +80,18 @@ public class DevuceServiceImpl implements DevuceService {
|
|||||||
bind(updateReqVO);
|
bind(updateReqVO);
|
||||||
return null;
|
return null;
|
||||||
}*/
|
}*/
|
||||||
try {
|
updateReqVO.setDeviceSn(this.getHearder());
|
||||||
String header = httpServletRequest.getHeader("Authorization");
|
|
||||||
updateReqVO.setDeviceSn(header);
|
|
||||||
bind(updateReqVO);
|
bind(updateReqVO);
|
||||||
|
}
|
||||||
|
public String getHearder(){
|
||||||
|
try {
|
||||||
|
return httpServletRequest.getHeader("Authorization");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw exception(2000_10_001,"无法获取设备编码");
|
throw exception(2000_10_001,"无法获取设备编码");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void bind(DevuceSaveReqVO updateReqVO){
|
public void bind(DevuceSaveReqVO updateReqVO){
|
||||||
if (devuceMapper.selectOne(new LambdaQueryWrapperX<DevuceDO>()
|
if (devuceMapper.selectList(new LambdaQueryWrapperX<DevuceDO>()
|
||||||
.eqIfPresent(DevuceDO::getDeviceSn,updateReqVO.getDeviceSn())) == null) {
|
.eqIfPresent(DevuceDO::getDeviceSn,updateReqVO.getDeviceSn())) == null) {
|
||||||
createDevuce(updateReqVO);
|
createDevuce(updateReqVO);
|
||||||
}else{
|
}else{
|
||||||
@ -123,10 +129,10 @@ public class DevuceServiceImpl implements DevuceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DishesDO getDevuceList(String sn) {
|
public DishesDO getDevuceList() {
|
||||||
//获取当前设备绑定的菜品id
|
//获取当前设备绑定的菜品id
|
||||||
DevuceDO devuceDO = devuceMapper.selectOne(new LambdaQueryWrapperX<DevuceDO>()
|
DevuceDO devuceDO = devuceMapper.selectOne(new LambdaQueryWrapperX<DevuceDO>()
|
||||||
.eq(DevuceDO::getDeviceSn, sn));
|
.eq(DevuceDO::getDeviceSn, this.getHearder()));
|
||||||
if(ObjUtil.isEmpty(devuceDO)){
|
if(ObjUtil.isEmpty(devuceDO)){
|
||||||
return null;
|
return null;
|
||||||
}else{
|
}else{
|
||||||
@ -168,5 +174,22 @@ public class DevuceServiceImpl implements DevuceService {
|
|||||||
return dishesTypeMapper.selectList(new LambdaQueryWrapperX<DishesTypeDO>().eq(DishesTypeDO::getCarteenId,carteenId));
|
return dishesTypeMapper.selectList(new LambdaQueryWrapperX<DishesTypeDO>().eq(DishesTypeDO::getCarteenId,carteenId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
* @Description: 根据ip获取门店id
|
||||||
|
* @Author: qjq
|
||||||
|
* @Date: 2024/4/10 下午4:28
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Long getCarteenIdByIp() {
|
||||||
|
String hearder = this.getHearder();
|
||||||
|
List<DeviceInfoDO> deviceInfoDOS = deviceInfoMapper.selectList(new LambdaQueryWrapperX<DeviceInfoDO>()
|
||||||
|
.eq(DeviceInfoDO::getDeviceIp, hearder)
|
||||||
|
);
|
||||||
|
if(ObjUtil.isNotEmpty(deviceInfoDOS)){
|
||||||
|
return deviceInfoDOS.get(0).getCarteenId();
|
||||||
|
}else{
|
||||||
|
throw exception(2000_10_002,"无法通IP获取门店");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user