package com.billion.main.bs.service.impl;
|
|
import java.util.Date;
|
import java.util.List;
|
|
import cn.hutool.core.collection.CollUtil;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.billion.common.core.domain.entity.SysUser;
|
import com.billion.common.core.domain.model.LoginUser;
|
import com.billion.common.exception.ServiceException;
|
import com.billion.common.utils.DateUtils;
|
import com.billion.common.utils.SecurityUtils;
|
import com.billion.main.bs.domain.BsFormulaInfo;
|
import com.billion.main.bs.mapper.BsFormulaInfoMapper;
|
import com.billion.main.bs.service.IBsFormulaInfoService;
|
import com.billion.main.common.BaseEntity;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
/**
|
* 配方配置Service业务层处理
|
*
|
* @author Billion
|
* @date 2024-11-26
|
*/
|
@Service
|
public class BsFormulaInfoServiceImpl extends ServiceImpl<BsFormulaInfoMapper, BsFormulaInfo> implements IBsFormulaInfoService
|
{
|
@Autowired
|
private BsFormulaInfoMapper bsFormulaInfoMapper;
|
|
/**
|
* 查询配方配置
|
*
|
* @param id 配方配置主键
|
* @return 配方配置
|
*/
|
@Override
|
public BsFormulaInfo selectBsFormulaInfoById(Long id)
|
{
|
return bsFormulaInfoMapper.selectBsFormulaInfoById(id);
|
}
|
|
/**
|
* 查询配方配置列表
|
*
|
* @param bsFormulaInfo 配方配置
|
* @return 配方配置
|
*/
|
@Override
|
public List<BsFormulaInfo> selectBsFormulaInfoList(BsFormulaInfo bsFormulaInfo)
|
{
|
return bsFormulaInfoMapper.selectBsFormulaInfoList(bsFormulaInfo);
|
}
|
|
/**
|
* 新增配方配置
|
*
|
* @param bsFormulaInfo 配方配置
|
* @return 结果
|
*/
|
@Override
|
public int insertBsFormulaInfo(BsFormulaInfo bsFormulaInfo)
|
{
|
List<BsFormulaInfo> check = this.list(new LambdaQueryWrapper<BsFormulaInfo>().eq(BsFormulaInfo::getFormulaCode, bsFormulaInfo.getFormulaCode()));
|
if (CollUtil.isNotEmpty(check)){
|
throw new ServiceException("已存在此配方编码");
|
}
|
List<BsFormulaInfo> check1 = this.list(new LambdaQueryWrapper<BsFormulaInfo>().eq(BsFormulaInfo::getProductCode, bsFormulaInfo.getProductCode()));
|
if (CollUtil.isNotEmpty(check1)){
|
throw new ServiceException("已存在此产品编码");
|
}
|
bsFormulaInfo.setCreateTime(DateUtils.getNowDate());
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
SysUser user = loginUser.getUser();
|
bsFormulaInfo.setCreateTime(new Date());
|
bsFormulaInfo.setUpdateTime(new Date());
|
bsFormulaInfo.setCreateBy(user.getUserName());
|
bsFormulaInfo.setUpdateBy(user.getUserName());
|
return bsFormulaInfoMapper.insertBsFormulaInfo(bsFormulaInfo);
|
}
|
|
/**
|
* 修改配方配置
|
*
|
* @param bsFormulaInfo 配方配置
|
* @return 结果
|
*/
|
@Override
|
public int updateBsFormulaInfo(BsFormulaInfo bsFormulaInfo)
|
{
|
List<BsFormulaInfo> check = this.list(new LambdaQueryWrapper<BsFormulaInfo>().eq(BsFormulaInfo::getFormulaCode, bsFormulaInfo.getFormulaCode())
|
.notIn(BaseEntity::getId,bsFormulaInfo.getId()));
|
if (CollUtil.isNotEmpty(check)){
|
throw new ServiceException("已存在此配方编码");
|
}
|
List<BsFormulaInfo> check1 = this.list(new LambdaQueryWrapper<BsFormulaInfo>().eq(BsFormulaInfo::getProductCode, bsFormulaInfo.getProductCode())
|
.notIn(BaseEntity::getId,bsFormulaInfo.getId()));
|
if (CollUtil.isNotEmpty(check1)){
|
throw new ServiceException("已存在此产品编码");
|
}
|
bsFormulaInfo.setUpdateTime(DateUtils.getNowDate());
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
SysUser user = loginUser.getUser();
|
bsFormulaInfo.setUpdateBy(user.getUserName());
|
return bsFormulaInfoMapper.updateBsFormulaInfo(bsFormulaInfo);
|
}
|
|
/**
|
* 批量删除配方配置
|
*
|
* @param ids 需要删除的配方配置主键
|
* @return 结果
|
*/
|
@Override
|
public int deleteBsFormulaInfoByIds(Long[] ids)
|
{
|
return bsFormulaInfoMapper.deleteBsFormulaInfoByIds(ids);
|
}
|
|
/**
|
* 删除配方配置信息
|
*
|
* @param id 配方配置主键
|
* @return 结果
|
*/
|
@Override
|
public int deleteBsFormulaInfoById(Long id)
|
{
|
return bsFormulaInfoMapper.deleteBsFormulaInfoById(id);
|
}
|
}
|