BomHeaderServiceImpl.java
2.24 KB
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
41
42
43
44
45
46
47
48
49
50
package com.huaheng.pc.config.bom.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.huaheng.common.utils.Wrappers;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.material.domain.Material;
import com.huaheng.pc.config.material.service.MaterialService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.pc.config.bom.domain.BomHeader;
import com.huaheng.pc.config.bom.mapper.BomHeaderMapper;
import javax.annotation.Resource;
import static com.huaheng.framework.web.domain.AjaxResult.toAjax;
@Service
public class BomHeaderServiceImpl extends ServiceImpl<BomHeaderMapper, BomHeader> implements BomHeaderService{
@Resource
private MaterialService materialService;
@Override
public AjaxResult dataValidation(BomHeader bomHeader) {
LambdaQueryWrapper<Material> lamdba = Wrappers.lambdaQuery();
lamdba.eq(Material::getCode, bomHeader.getMaterialCode());
Material material = materialService.getOne(lamdba);
if ( material == null){
return AjaxResult.error("不存在物料编码"+bomHeader.getMaterialCode());
} else {
bomHeader.setCompanyCode(material.getCompanyCode());
bomHeader.setWarehouseCode(material.getWarehouseCode());
bomHeader.setMaterialCode(material.getCode());
bomHeader.setMaterialName(material.getName());
bomHeader.setMaterialSpec(material.getSpec());
bomHeader.setMaterialUnit(material.getUnit());
bomHeader.setCreatedBy(ShiroUtils.getLoginName());
bomHeader.setLastUpdatedBy(ShiroUtils.getLoginName());
}
LambdaQueryWrapper<BomHeader> query = Wrappers.lambdaQuery();
query.eq(BomHeader::getMaterialCode, bomHeader.getMaterialCode()).
eq(BomHeader::getCompanyCode, bomHeader.getCompanyCode()).
eq(BomHeader::getWarehouseCode, bomHeader.getWarehouseCode());
if (this.getOne(query) != null){
return AjaxResult.error("数据已存在请勿重复添加!");
}
return toAjax(this.save(bomHeader));
}
}