ZoneCapacityServiceImpl.java
2.31 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
package com.huaheng.pc.config.zoneCapacity.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.huaheng.common.utils.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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.zoneCapacity.domain.ZoneCapacity;
import com.huaheng.pc.config.zoneCapacity.mapper.ZoneCapacityMapper;
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;
@Service
public class ZoneCapacityServiceImpl extends ServiceImpl<ZoneCapacityMapper, ZoneCapacity> implements ZoneCapacityService {
@Autowired
private MaterialService materialService;
//添加库区容量时,查找到该物料的具体信息,一并加入到库区容量中
@Override
public AjaxResult insertModel(ZoneCapacity zoneCapacity) {
zoneCapacity.setWarehouseCode(ShiroUtils.getWarehouseCode());
zoneCapacity.setCreatedBy(ShiroUtils.getLoginName());
zoneCapacity.setLastUpdatedBy(ShiroUtils.getLoginName());
if(StringUtils.isEmpty(zoneCapacity.getMaterialCode())){
return AjaxResult.error("没有输入物料编码");
}
//查找该物料信息
LambdaQueryWrapper<Material> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(StringUtils.isNotEmpty(zoneCapacity.getMaterialCode()),Material::getCode, zoneCapacity.getMaterialCode())
.eq(StringUtils.isNotEmpty(zoneCapacity.getWarehouseCode()),Material::getWarehouseCode, zoneCapacity.getWarehouseCode());
Material material=materialService.getOne(lambdaQueryWrapper);
if(material==null){
return AjaxResult.error("系统没有该物料");
}
zoneCapacity.setMaterialName(material.getName());
zoneCapacity.setMaterialSpec(material.getSpec());
zoneCapacity.setMaterialUnit(material.getUnit());
if(!this.save(zoneCapacity)){
return AjaxResult.error("新增库区容量失败");
}
return AjaxResult.success("新增库区容量成功");
}
}