干燥机配套车间生产管理系统/云平台服务端
baoshiwei
2025-11-28 567096dae7f467d04883f11b17f667b6cef5f536
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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;
 
/**
 * @Description: 干燥配方
 * @Author: jeecg-boot
 * @Date:   2023-05-16
 * @Version: V1.0
 */
@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);
        }
    }
}