mirror of https://github.com/elunez/eladmin
新增物料资料
parent
faea62a149
commit
e07d04e1ba
|
@ -3,6 +3,8 @@ package me.zhengjie.modules.wms.bd.domain;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.bean.copier.CopyOptions;
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
|
import org.hibernate.annotations.CreationTimestamp;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
@ -20,11 +22,11 @@ public class MaterialInfo implements Serializable {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "id")
|
@Column(name = "id")
|
||||||
private Integer id;
|
private long id;
|
||||||
|
|
||||||
// 所属物料分类主键
|
// 所属物料分类主键
|
||||||
@Column(name = "material_category_id",nullable = false)
|
@Column(name = "material_category_id",nullable = false)
|
||||||
private Integer materialCategoryId;
|
private long materialCategoryId;
|
||||||
|
|
||||||
// 物料分类名称
|
// 物料分类名称
|
||||||
@Column(name = "material_category_name",nullable = false)
|
@Column(name = "material_category_name",nullable = false)
|
||||||
|
@ -34,13 +36,17 @@ public class MaterialInfo implements Serializable {
|
||||||
@Column(name = "name")
|
@Column(name = "name")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
// 物料编码
|
||||||
|
@Column(name = "material_code")
|
||||||
|
private String materialCode;
|
||||||
|
|
||||||
// 物料规格
|
// 物料规格
|
||||||
@Column(name = "specifications")
|
@Column(name = "specifications")
|
||||||
private String specifications;
|
private String specifications;
|
||||||
|
|
||||||
// 所属计量单位主键
|
// 所属计量单位主键
|
||||||
@Column(name = "measure_unit_id")
|
@Column(name = "measure_unit_id")
|
||||||
private Integer measureUnitId;
|
private Long measureUnitId;
|
||||||
|
|
||||||
// 所属计量单位名称
|
// 所属计量单位名称
|
||||||
@Column(name = "measure_unit_name")
|
@Column(name = "measure_unit_name")
|
||||||
|
@ -65,10 +71,12 @@ public class MaterialInfo implements Serializable {
|
||||||
|
|
||||||
// 创建时间
|
// 创建时间
|
||||||
@Column(name = "create_time")
|
@Column(name = "create_time")
|
||||||
|
@CreationTimestamp
|
||||||
private Timestamp createTime;
|
private Timestamp createTime;
|
||||||
|
|
||||||
// 更新时间
|
// 更新时间
|
||||||
@Column(name = "update_time")
|
@Column(name = "update_time")
|
||||||
|
@CreationTimestamp
|
||||||
private Timestamp updateTime;
|
private Timestamp updateTime;
|
||||||
|
|
||||||
public void copy(MaterialInfo source){
|
public void copy(MaterialInfo source){
|
||||||
|
|
|
@ -10,4 +10,10 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
*/
|
*/
|
||||||
public interface MaterialCategoryRepository extends JpaRepository<MaterialCategory, Long >, JpaSpecificationExecutor {
|
public interface MaterialCategoryRepository extends JpaRepository<MaterialCategory, Long >, JpaSpecificationExecutor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询存在的物料资料
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
MaterialCategory findByIdAndStatusTrue(long id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,5 +8,5 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
* @author 黄星星
|
* @author 黄星星
|
||||||
* @date 2019-07-27
|
* @date 2019-07-27
|
||||||
*/
|
*/
|
||||||
public interface MaterialInfoRepository extends JpaRepository<MaterialInfo, Integer>, JpaSpecificationExecutor {
|
public interface MaterialInfoRepository extends JpaRepository<MaterialInfo, Long>, JpaSpecificationExecutor {
|
||||||
}
|
}
|
|
@ -10,4 +10,10 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
*/
|
*/
|
||||||
public interface MeasureUnitRepository extends JpaRepository<MeasureUnit, Long >, JpaSpecificationExecutor {
|
public interface MeasureUnitRepository extends JpaRepository<MeasureUnit, Long >, JpaSpecificationExecutor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据主键查询状态正常的计量单位
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
MeasureUnit findByIdAndStatusTrue(long id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public interface MaterialInfoService {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
//@Cacheable(key = "#p0")
|
//@Cacheable(key = "#p0")
|
||||||
MaterialInfoDTO findById(Integer id);
|
MaterialInfoDTO findById(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create
|
* create
|
||||||
|
@ -60,5 +60,5 @@ public interface MaterialInfoService {
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
//@CacheEvict(allEntries = true)
|
//@CacheEvict(allEntries = true)
|
||||||
void delete(Integer id);
|
void delete(long id);
|
||||||
}
|
}
|
|
@ -43,20 +43,10 @@ public class ProductInfoDTO implements Serializable {
|
||||||
private String productInventoryWarning;
|
private String productInventoryWarning;
|
||||||
|
|
||||||
// 产品期初设置
|
// 产品期初设置
|
||||||
[ {
|
// [{“sort”:””,”ware_house_code”:””,”ware_house_name”:””,”ware_house_type_code”:””,“ ware_house_type_name”:””,
|
||||||
“sort”:””,
|
// “material_code”:””,“material_name”:””,“specifications”:””,“unit_price”:””,
|
||||||
”ware_house_code”:””,
|
// “total_price”:””,”minimum_inventory”:””,”highest_inventory”:””
|
||||||
”ware_house_name”:””,
|
// }]
|
||||||
”ware_house_type_code”:””,
|
|
||||||
“ ware_house_type_name”:””,
|
|
||||||
“material_code”:””,
|
|
||||||
“material_name”:””,
|
|
||||||
“specifications”:””,
|
|
||||||
“unit_price”:””,
|
|
||||||
“total_price”:””,
|
|
||||||
”minimum_inventory”:””,
|
|
||||||
”highest_inventory”:””
|
|
||||||
}]
|
|
||||||
private String productInitialSetup;
|
private String productInitialSetup;
|
||||||
|
|
||||||
// 创建时间
|
// 创建时间
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
package me.zhengjie.modules.wms.bd.service.impl;
|
package me.zhengjie.modules.wms.bd.service.impl;
|
||||||
|
|
||||||
|
import me.zhengjie.exception.BadRequestException;
|
||||||
|
import me.zhengjie.modules.wms.bd.domain.MaterialCategory;
|
||||||
import me.zhengjie.modules.wms.bd.domain.MaterialInfo;
|
import me.zhengjie.modules.wms.bd.domain.MaterialInfo;
|
||||||
|
import me.zhengjie.modules.wms.bd.domain.MeasureUnit;
|
||||||
|
import me.zhengjie.modules.wms.bd.repository.MaterialCategoryRepository;
|
||||||
|
import me.zhengjie.modules.wms.bd.repository.MeasureUnitRepository;
|
||||||
import me.zhengjie.utils.ValidationUtil;
|
import me.zhengjie.utils.ValidationUtil;
|
||||||
import me.zhengjie.modules.wms.bd.repository.MaterialInfoRepository;
|
import me.zhengjie.modules.wms.bd.repository.MaterialInfoRepository;
|
||||||
import me.zhengjie.modules.wms.bd.service.MaterialInfoService;
|
import me.zhengjie.modules.wms.bd.service.MaterialInfoService;
|
||||||
|
@ -16,6 +21,7 @@ import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import me.zhengjie.utils.PageUtil;
|
import me.zhengjie.utils.PageUtil;
|
||||||
import me.zhengjie.utils.QueryHelp;
|
import me.zhengjie.utils.QueryHelp;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 黄星星
|
* @author 黄星星
|
||||||
|
@ -31,6 +37,12 @@ public class MaterialInfoServiceImpl implements MaterialInfoService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private MaterialInfoMapper materialInfoMapper;
|
private MaterialInfoMapper materialInfoMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MaterialCategoryRepository materialCategoryRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MeasureUnitRepository measureUnitRepository;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object queryAll(MaterialInfoQueryCriteria criteria, Pageable pageable){
|
public Object queryAll(MaterialInfoQueryCriteria criteria, Pageable pageable){
|
||||||
Page<MaterialInfo> page = materialInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
Page<MaterialInfo> page = materialInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||||
|
@ -43,7 +55,7 @@ public class MaterialInfoServiceImpl implements MaterialInfoService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MaterialInfoDTO findById(Integer id) {
|
public MaterialInfoDTO findById(Long id) {
|
||||||
Optional<MaterialInfo> bdMaterialInfo = materialInfoRepository.findById(id);
|
Optional<MaterialInfo> bdMaterialInfo = materialInfoRepository.findById(id);
|
||||||
ValidationUtil.isNull(bdMaterialInfo,"BdMaterialInfo","id",id);
|
ValidationUtil.isNull(bdMaterialInfo,"BdMaterialInfo","id",id);
|
||||||
return materialInfoMapper.toDto(bdMaterialInfo.get());
|
return materialInfoMapper.toDto(bdMaterialInfo.get());
|
||||||
|
@ -52,6 +64,27 @@ public class MaterialInfoServiceImpl implements MaterialInfoService {
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public MaterialInfoDTO create(MaterialInfo resources) {
|
public MaterialInfoDTO create(MaterialInfo resources) {
|
||||||
|
Long materialCategoryId = resources.getMaterialCategoryId();
|
||||||
|
String materialCategoryName = resources.getMaterialCategoryName();
|
||||||
|
if(null == materialCategoryId || StringUtils.isEmpty(materialCategoryName)){
|
||||||
|
throw new BadRequestException("物料类别不能为空!");
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialCategory materialCategory = materialCategoryRepository.findByIdAndStatusTrue(materialCategoryId);
|
||||||
|
if(null == materialCategory){
|
||||||
|
throw new BadRequestException("物料类别不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
Long measureUnitId = resources.getMeasureUnitId();
|
||||||
|
String measureUnitName = resources.getMeasureUnitName();
|
||||||
|
if(null == measureUnitId || StringUtils.isEmpty(measureUnitName)){
|
||||||
|
throw new BadRequestException("计量单位不能为空!");
|
||||||
|
}
|
||||||
|
|
||||||
|
MeasureUnit measureUnit = measureUnitRepository.findByIdAndStatusTrue(measureUnitId);
|
||||||
|
if(null == measureUnit){
|
||||||
|
throw new BadRequestException("计量单位不存在!");
|
||||||
|
}
|
||||||
return materialInfoMapper.toDto(materialInfoRepository.save(resources));
|
return materialInfoMapper.toDto(materialInfoRepository.save(resources));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +92,7 @@ public class MaterialInfoServiceImpl implements MaterialInfoService {
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(MaterialInfo resources) {
|
public void update(MaterialInfo resources) {
|
||||||
Optional<MaterialInfo> optionalBdMaterialInfo = materialInfoRepository.findById(resources.getId());
|
Optional<MaterialInfo> optionalBdMaterialInfo = materialInfoRepository.findById(resources.getId());
|
||||||
ValidationUtil.isNull( optionalBdMaterialInfo,"BdMaterialInfo","id",resources.getId());
|
ValidationUtil.isNull( optionalBdMaterialInfo,"MaterialInfo","id",resources.getId());
|
||||||
MaterialInfo materialInfo = optionalBdMaterialInfo.get();
|
MaterialInfo materialInfo = optionalBdMaterialInfo.get();
|
||||||
materialInfo.copy(resources);
|
materialInfo.copy(resources);
|
||||||
materialInfoRepository.save(materialInfo);
|
materialInfoRepository.save(materialInfo);
|
||||||
|
@ -67,7 +100,7 @@ public class MaterialInfoServiceImpl implements MaterialInfoService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void delete(Integer id) {
|
public void delete(long id) {
|
||||||
materialInfoRepository.deleteById(id);
|
materialInfoRepository.deleteById(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue