提交 | 用户 | 时间
|
fb3b3e
|
1 |
package com.billion.main.bs.service.impl; |
吴 |
2 |
|
|
3 |
import java.util.Date; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import cn.hutool.core.collection.CollUtil; |
|
7 |
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
8 |
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
9 |
import com.billion.common.core.domain.entity.SysUser; |
|
10 |
import com.billion.common.core.domain.model.LoginUser; |
|
11 |
import com.billion.common.exception.ServiceException; |
|
12 |
import com.billion.common.utils.DateUtils; |
|
13 |
import com.billion.common.utils.SecurityUtils; |
|
14 |
import com.billion.main.bs.domain.BsFormulaInfo; |
|
15 |
import com.billion.main.bs.mapper.BsFormulaInfoMapper; |
|
16 |
import com.billion.main.bs.service.IBsFormulaInfoService; |
|
17 |
import com.billion.main.common.BaseEntity; |
|
18 |
import org.springframework.beans.factory.annotation.Autowired; |
|
19 |
import org.springframework.stereotype.Service; |
|
20 |
|
|
21 |
/** |
|
22 |
* 配方配置Service业务层处理 |
|
23 |
* |
|
24 |
* @author Billion |
|
25 |
* @date 2024-11-26 |
|
26 |
*/ |
|
27 |
@Service |
|
28 |
public class BsFormulaInfoServiceImpl extends ServiceImpl<BsFormulaInfoMapper, BsFormulaInfo> implements IBsFormulaInfoService |
|
29 |
{ |
|
30 |
@Autowired |
|
31 |
private BsFormulaInfoMapper bsFormulaInfoMapper; |
|
32 |
|
|
33 |
/** |
|
34 |
* 查询配方配置 |
|
35 |
* |
|
36 |
* @param id 配方配置主键 |
|
37 |
* @return 配方配置 |
|
38 |
*/ |
|
39 |
@Override |
|
40 |
public BsFormulaInfo selectBsFormulaInfoById(Long id) |
|
41 |
{ |
|
42 |
return bsFormulaInfoMapper.selectBsFormulaInfoById(id); |
|
43 |
} |
|
44 |
|
|
45 |
/** |
|
46 |
* 查询配方配置列表 |
|
47 |
* |
|
48 |
* @param bsFormulaInfo 配方配置 |
|
49 |
* @return 配方配置 |
|
50 |
*/ |
|
51 |
@Override |
|
52 |
public List<BsFormulaInfo> selectBsFormulaInfoList(BsFormulaInfo bsFormulaInfo) |
|
53 |
{ |
|
54 |
return bsFormulaInfoMapper.selectBsFormulaInfoList(bsFormulaInfo); |
|
55 |
} |
|
56 |
|
|
57 |
/** |
|
58 |
* 新增配方配置 |
|
59 |
* |
|
60 |
* @param bsFormulaInfo 配方配置 |
|
61 |
* @return 结果 |
|
62 |
*/ |
|
63 |
@Override |
|
64 |
public int insertBsFormulaInfo(BsFormulaInfo bsFormulaInfo) |
|
65 |
{ |
|
66 |
List<BsFormulaInfo> check = this.list(new LambdaQueryWrapper<BsFormulaInfo>().eq(BsFormulaInfo::getFormulaCode, bsFormulaInfo.getFormulaCode())); |
|
67 |
if (CollUtil.isNotEmpty(check)){ |
|
68 |
throw new ServiceException("已存在此配方编码"); |
|
69 |
} |
|
70 |
List<BsFormulaInfo> check1 = this.list(new LambdaQueryWrapper<BsFormulaInfo>().eq(BsFormulaInfo::getProductCode, bsFormulaInfo.getProductCode())); |
|
71 |
if (CollUtil.isNotEmpty(check1)){ |
|
72 |
throw new ServiceException("已存在此产品编码"); |
|
73 |
} |
|
74 |
bsFormulaInfo.setCreateTime(DateUtils.getNowDate()); |
|
75 |
LoginUser loginUser = SecurityUtils.getLoginUser(); |
|
76 |
SysUser user = loginUser.getUser(); |
|
77 |
bsFormulaInfo.setCreateTime(new Date()); |
|
78 |
bsFormulaInfo.setUpdateTime(new Date()); |
|
79 |
bsFormulaInfo.setCreateBy(user.getUserName()); |
|
80 |
bsFormulaInfo.setUpdateBy(user.getUserName()); |
|
81 |
return bsFormulaInfoMapper.insertBsFormulaInfo(bsFormulaInfo); |
|
82 |
} |
|
83 |
|
|
84 |
/** |
|
85 |
* 修改配方配置 |
|
86 |
* |
|
87 |
* @param bsFormulaInfo 配方配置 |
|
88 |
* @return 结果 |
|
89 |
*/ |
|
90 |
@Override |
|
91 |
public int updateBsFormulaInfo(BsFormulaInfo bsFormulaInfo) |
|
92 |
{ |
|
93 |
List<BsFormulaInfo> check = this.list(new LambdaQueryWrapper<BsFormulaInfo>().eq(BsFormulaInfo::getFormulaCode, bsFormulaInfo.getFormulaCode()) |
|
94 |
.notIn(BaseEntity::getId,bsFormulaInfo.getId())); |
|
95 |
if (CollUtil.isNotEmpty(check)){ |
|
96 |
throw new ServiceException("已存在此配方编码"); |
|
97 |
} |
|
98 |
List<BsFormulaInfo> check1 = this.list(new LambdaQueryWrapper<BsFormulaInfo>().eq(BsFormulaInfo::getProductCode, bsFormulaInfo.getProductCode()) |
|
99 |
.notIn(BaseEntity::getId,bsFormulaInfo.getId())); |
|
100 |
if (CollUtil.isNotEmpty(check1)){ |
|
101 |
throw new ServiceException("已存在此产品编码"); |
|
102 |
} |
|
103 |
bsFormulaInfo.setUpdateTime(DateUtils.getNowDate()); |
|
104 |
LoginUser loginUser = SecurityUtils.getLoginUser(); |
|
105 |
SysUser user = loginUser.getUser(); |
|
106 |
bsFormulaInfo.setUpdateBy(user.getUserName()); |
|
107 |
return bsFormulaInfoMapper.updateBsFormulaInfo(bsFormulaInfo); |
|
108 |
} |
|
109 |
|
|
110 |
/** |
|
111 |
* 批量删除配方配置 |
|
112 |
* |
|
113 |
* @param ids 需要删除的配方配置主键 |
|
114 |
* @return 结果 |
|
115 |
*/ |
|
116 |
@Override |
|
117 |
public int deleteBsFormulaInfoByIds(Long[] ids) |
|
118 |
{ |
|
119 |
return bsFormulaInfoMapper.deleteBsFormulaInfoByIds(ids); |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
123 |
* 删除配方配置信息 |
|
124 |
* |
|
125 |
* @param id 配方配置主键 |
|
126 |
* @return 结果 |
|
127 |
*/ |
|
128 |
@Override |
|
129 |
public int deleteBsFormulaInfoById(Long id) |
|
130 |
{ |
|
131 |
return bsFormulaInfoMapper.deleteBsFormulaInfoById(id); |
|
132 |
} |
|
133 |
} |