ContainerCapacityServiceImpl.java
3.14 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
51
52
53
54
55
56
57
58
59
package com.huaheng.pc.config.containerCapacity.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.huaheng.common.utils.Wrappers;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.containerType.domain.ContainerType;
import com.huaheng.pc.config.containerType.service.ContainerTypeService;
import com.huaheng.pc.config.material.domain.Material;
import com.huaheng.pc.config.material.service.MaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.pc.config.containerCapacity.mapper.ContainerCapacityMapper;
import com.huaheng.pc.config.containerCapacity.domain.ContainerCapacity;
@Service
public class ContainerCapacityServiceImpl extends ServiceImpl<ContainerCapacityMapper, ContainerCapacity> implements ContainerCapacityService{
@Autowired
private MaterialService materialService;
@Autowired
private ContainerTypeService containerTypeService;
//判断容器类别是否存在,添加容器容量时,查找到该物料的具体信息,一并加入到容器容量中
@Override
public AjaxResult insertModel(ContainerCapacity containerCapacity) {
containerCapacity.setWarehouseCode(ShiroUtils.getWarehouseCode());
containerCapacity.setCreatedBy(ShiroUtils.getLoginName());
containerCapacity.setLastUpdatedBy(ShiroUtils.getLoginName());
//查找该容器类别信息
LambdaQueryWrapper<ContainerType> lambdaQueryWrappers = Wrappers.lambdaQuery();
lambdaQueryWrappers.eq(StringUtils.isNotEmpty(containerCapacity.getContainerType()),ContainerType::getCode, containerCapacity.getContainerType())
.eq(StringUtils.isNotEmpty(containerCapacity.getWarehouseCode()),ContainerType::getWarehouseCode, containerCapacity.getWarehouseCode());
ContainerType containerType=containerTypeService.getOne(lambdaQueryWrappers);
if(containerType==null){
return AjaxResult.error("系统没有该容器类型");
}
//查找该物料信息
LambdaQueryWrapper<Material> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(StringUtils.isNotEmpty(containerCapacity.getMaterialCode()),Material::getCode, containerCapacity.getMaterialCode())
.eq(StringUtils.isNotEmpty(containerCapacity.getWarehouseCode()),Material::getWarehouseCode, containerCapacity.getWarehouseCode());
Material material=materialService.getOne(lambdaQueryWrapper);
if(material==null){
return AjaxResult.error("系统没有该物料");
}
containerCapacity.setMaterialName(material.getName());
containerCapacity.setMaterialSpec(material.getSpec());
containerCapacity.setMaterialUnit(material.getUnit());
if(!this.save(containerCapacity)){
return AjaxResult.error("新增容器容量失败");
}
return AjaxResult.success("新增容器容量成功");
}
}