菜品绑定修改
This commit is contained in:
@ -75,7 +75,7 @@ public class DevuceController {
|
||||
}
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得绑定的菜品")
|
||||
public CommonResult<DishesRespVO> getDevuceList(@RequestParam("sn")String sn) {
|
||||
public CommonResult<DishesRespVO> getDevuceList(@RequestParam("sn")String sn){
|
||||
DishesDO devuceList = devuceService.getDevuceList(sn);
|
||||
return success(BeanUtils.toBean(devuceList, DishesRespVO.class));
|
||||
}
|
||||
|
@ -3,8 +3,8 @@ package cn.iocoder.yudao.module.system.controller.app.devuce.vo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Schema(description = "管理后台 - 设备新增/修改 Request VO")
|
||||
@Data
|
||||
@ -13,8 +13,7 @@ public class DevuceSaveReqVO {
|
||||
@Schema(description = "设备编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11545")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "设备SN码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "设备SN码不能为空")
|
||||
|
||||
private String deviceSn;
|
||||
|
||||
@Schema(description = "菜品id", example = "17970")
|
||||
@ -25,4 +24,13 @@ public class DevuceSaveReqVO {
|
||||
@NotNull(message = "是否绑定不能为空")
|
||||
private Boolean bind;
|
||||
|
||||
@Schema(description = "菜品总重量")
|
||||
private BigDecimal totalWeight;
|
||||
|
||||
@Schema(description = "变化重量")
|
||||
private BigDecimal diff;
|
||||
|
||||
@Schema(description = "剩余重量")
|
||||
private BigDecimal remWeight;
|
||||
|
||||
}
|
@ -1,11 +1,12 @@
|
||||
package cn.iocoder.yudao.module.system.dal.dataobject.devuce;
|
||||
|
||||
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;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 设备 DO
|
||||
@ -41,5 +42,17 @@ public class DevuceDO extends BaseDO {
|
||||
* 是否绑定
|
||||
*/
|
||||
private Boolean bind;
|
||||
/**
|
||||
* 菜品总重量
|
||||
*/
|
||||
private BigDecimal totalWeight;
|
||||
|
||||
/**
|
||||
* 菜品变化重量
|
||||
*/
|
||||
private BigDecimal diff;
|
||||
/**
|
||||
* 菜品剩余重量
|
||||
*/
|
||||
private BigDecimal remWeight;
|
||||
}
|
@ -54,7 +54,14 @@ public interface DevuceService {
|
||||
* @return 设备分页
|
||||
*/
|
||||
PageResult<DevuceDO> getDevucePage(DevucePageReqVO pageReqVO);
|
||||
/**
|
||||
* @Description: 设备绑定菜品,或计算菜品重量与剩余重量
|
||||
* @Author: qjq
|
||||
* @Date: 2024/4/10 下午1:40
|
||||
* @return
|
||||
*/
|
||||
DishesDO getDevuceList(String sn);
|
||||
|
||||
List<DishesDO> getDishesList(Long carteenId,Long dishecType);
|
||||
/**
|
||||
* @Description: 获取菜品分类
|
||||
@ -63,4 +70,7 @@ public interface DevuceService {
|
||||
* @return
|
||||
*/
|
||||
List<DishesTypeDO> getDishesTypeList(Long carteenId);
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package cn.iocoder.yudao.module.system.service.devuce;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
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.DevuceSaveReqVO;
|
||||
@ -18,6 +18,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -38,10 +39,12 @@ public class DevuceServiceImpl implements DevuceService {
|
||||
private DishesMapper dishesMapper;
|
||||
@Resource
|
||||
private DishesTypeMapper dishesTypeMapper;
|
||||
@Resource
|
||||
private HttpServletRequest httpServletRequest;
|
||||
@Override
|
||||
public Long createDevuce(DevuceSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
DevuceDO devuce = BeanUtils.toBean(createReqVO, DevuceDO.class);
|
||||
DevuceDO devuce = BeanUtil.toBean(createReqVO, DevuceDO.class);
|
||||
devuceMapper.insert(devuce);
|
||||
// 返回
|
||||
return devuce.getId();
|
||||
@ -51,6 +54,37 @@ public class DevuceServiceImpl implements DevuceService {
|
||||
@Override
|
||||
public void updateDevuce(DevuceSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
/*if (ObjUtil.isNotEmpty(updateReqVO.getRemWeight())
|
||||
|| ObjUtil.isNotEmpty(updateReqVO.getTotalWeight())
|
||||
|| ObjUtil.isNotEmpty(updateReqVO.getDiff())) {
|
||||
//进行计算总量数据
|
||||
if (ObjUtil.isEmpty(updateReqVO.getDiff())) {
|
||||
//第一次绑定
|
||||
updateReqVO.setRemWeight(updateReqVO.getTotalWeight());
|
||||
bind(updateReqVO);
|
||||
return updateReqVO;
|
||||
} else {
|
||||
BigDecimal remWeight = updateReqVO.getRemWeight();
|
||||
BigDecimal diff = updateReqVO.getDiff();
|
||||
//下一次剩余的重量
|
||||
BigDecimal subtract = remWeight.subtract(diff);
|
||||
updateReqVO.setRemWeight(subtract);
|
||||
bind(updateReqVO);
|
||||
return updateReqVO;
|
||||
}
|
||||
}else{
|
||||
bind(updateReqVO);
|
||||
return null;
|
||||
}*/
|
||||
try {
|
||||
String header = httpServletRequest.getHeader("Authorization");
|
||||
updateReqVO.setDeviceSn(header);
|
||||
bind(updateReqVO);
|
||||
} catch (Exception e) {
|
||||
throw exception(2000_10_001,"无法获取设备编码");
|
||||
}
|
||||
}
|
||||
public void bind(DevuceSaveReqVO updateReqVO){
|
||||
if (devuceMapper.selectOne(new LambdaQueryWrapperX<DevuceDO>()
|
||||
.eqIfPresent(DevuceDO::getDeviceSn,updateReqVO.getDeviceSn())) == null) {
|
||||
createDevuce(updateReqVO);
|
||||
@ -64,7 +98,6 @@ public class DevuceServiceImpl implements DevuceService {
|
||||
createDevuce(updateReqVO);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDevuce(Long id) {
|
||||
// 校验存在
|
||||
@ -134,4 +167,6 @@ public class DevuceServiceImpl implements DevuceService {
|
||||
public List<DishesTypeDO> getDishesTypeList(Long carteenId) {
|
||||
return dishesTypeMapper.selectList(new LambdaQueryWrapperX<DishesTypeDO>().eq(DishesTypeDO::getCarteenId,carteenId));
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user