| | |
| | | package org.jeecg.modules.dry.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import org.jeecg.modules.dry.Bo.HerbFormulaBo; |
| | | import org.jeecg.modules.dry.entity.DryHerbFormula; |
| | | import org.jeecg.modules.dry.mapper.DryHerbFormulaMapper; |
| | | import org.jeecg.modules.dry.service.IDryHerbFormulaService; |
| | | import org.jeecg.modules.dry.vo.HerbFormulaVo; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | @Service |
| | | public class DryHerbFormulaServiceImpl extends ServiceImpl<DryHerbFormulaMapper, DryHerbFormula> implements IDryHerbFormulaService { |
| | | |
| | | @Override |
| | | public void saveOrUpdateFormula(HerbFormulaBo formulaBo) { |
| | | DryHerbFormula formula = new DryHerbFormula(formulaBo); |
| | | LambdaQueryWrapper<DryHerbFormula> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(DryHerbFormula::getEqpType, formula.getEqpType()); |
| | | queryWrapper.eq(DryHerbFormula::getName, formula.getName()); |
| | | |
| | | |
| | | DryHerbFormula existingFormula = baseMapper.selectOne(queryWrapper); |
| | | if (existingFormula != null) { |
| | | // 如果存在,则更新记录,需要设置ID以确保更新正确的记录 |
| | | formula.setId(existingFormula.getId()); |
| | | updateById(formula); |
| | | } else { |
| | | // 如果不存在,则插入新记录 |
| | | save( formula); |
| | | } |
| | | } |
| | | } |