|
1
2
|
package com.huaheng.pc.config.zoneCapacity.service;
|
|
3
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
4
|
import com.huaheng.common.utils.Wrappers;
|
|
5
6
7
8
9
10
|
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;
|
|
11
12
|
import com.huaheng.pc.config.material.domain.Material;
import com.huaheng.pc.config.material.service.MaterialService;
|
|
13
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
14
15
16
17
|
import org.springframework.stereotype.Service;
@Service
public class ZoneCapacityServiceImpl extends ServiceImpl<ZoneCapacityMapper, ZoneCapacity> implements ZoneCapacityService {
|
|
18
19
20
21
|
@Autowired
private MaterialService materialService;
//添加库区容量时,查找到该物料的具体信息,一并加入到库区容量中
|
|
22
23
|
@Override
public AjaxResult insertModel(ZoneCapacity zoneCapacity) {
|
|
24
|
zoneCapacity.setWarehouseCode(ShiroUtils.getWarehouseCode());
|
|
25
26
27
28
29
30
|
zoneCapacity.setCreatedBy(ShiroUtils.getLoginName());
zoneCapacity.setLastUpdatedBy(ShiroUtils.getLoginName());
if(StringUtils.isEmpty(zoneCapacity.getMaterialCode())){
return AjaxResult.error("没有输入物料编码");
}
|
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
//查找该物料信息
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("新增库区容量失败");
}
|
|
45
46
47
|
return AjaxResult.success("新增库区容量成功");
}
}
|