物料管理

pull/451/head
starrysky 2019-07-28 09:13:14 +08:00
parent d471b797c2
commit faea62a149
16 changed files with 755 additions and 0 deletions

View File

@ -0,0 +1,77 @@
package me.zhengjie.modules.wms.bd.domain;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @author
* @date 2019-07-27
*/
@Entity
@Data
@Table(name="bd_material_info")
public class MaterialInfo implements Serializable {
// 主键
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Integer id;
// 所属物料分类主键
@Column(name = "material_category_id",nullable = false)
private Integer materialCategoryId;
// 物料分类名称
@Column(name = "material_category_name",nullable = false)
private String materialCategoryName;
// 物料名称
@Column(name = "name")
private String name;
// 物料规格
@Column(name = "specifications")
private String specifications;
// 所属计量单位主键
@Column(name = "measure_unit_id")
private Integer measureUnitId;
// 所属计量单位名称
@Column(name = "measure_unit_name")
private String measureUnitName;
// 产品库存预警[{“sort”:””,”ware_house_code”:””,”ware_house_name”:””,”minimum_inventory”:””,”highest_inventory”:””}]
@Column(name = "material_inventory_warning")
private String materialInventoryWarning;
// 产品期初设置[{“sort”:””,”ware_house_code”:””,”ware_house_name”:””,“initial_setup_numer”:””,“initial_setup_total_price”:””}]
@Column(name = "material_initial_setup")
private String materialInitialSetup;
// 物料期初合计期初总价格
@Column(name = "material_initial_setup_total_price")
private Integer materialInitialSetupTotalPrice;
// 物料期初合计总数量
@Column(name = "material_initial_setup_total_number")
private String materialInitialSetupTotalNumber;
// 创建时间
@Column(name = "create_time")
private Timestamp createTime;
// 更新时间
@Column(name = "update_time")
private Timestamp updateTime;
public void copy(MaterialInfo source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -0,0 +1,79 @@
package me.zhengjie.modules.wms.bd.domain;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @author
* @date 2019-07-27
*/
@Entity
@Data
@Table(name="bd_product_info")
public class ProductInfo implements Serializable {
// 主键
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Integer id;
// 所属产品分类
@Column(name = "product_category_id",nullable = false)
private Integer productCategoryId;
// 产品分类名称
@Column(name = "product_category_name",nullable = false)
private String productCategoryName;
// 产品编号
@Column(name = "product_code")
private String productCode;
// 产品名称
@Column(name = "name")
private String name;
// 产品规格
@Column(name = "specifications")
private String specifications;
// 所属计量单位主键
@Column(name = "measure_unit_id")
private Integer measureUnitId;
// 所属计量单位名称
@Column(name = "measure_unit_name")
private String measureUnitName;
// 产品单价(保留两位小数) 单位:元
@Column(name = "unit_price")
private Integer unitPrice;
// 产品库存预警[{“sort”:1,”ware_house_code”:””,”ware_house_name”:””,”minimum_inventory”:””,”highest_inventory”:””}]
@Column(name = "product_inventory_warning")
private String productInventoryWarning;
// 产品期初设置
//[{“sort”:””,”ware_house_code”:””,”ware_house_name”:””,”ware_house_type_code”:””,“ ware_house_type_name”:””,
//“material_code”:””,“material_name”:””,“specifications”:””,“unit_price”:””,“total_price”:””,
//”minimum_inventory”:””,”highest_inventory”:””}]
@Column(name = "product_initial_setup")
private String productInitialSetup;
// 创建时间
@Column(name = "create_time")
private Timestamp createTime;
// 更新时间
@Column(name = "update_time")
private Timestamp updateTime;
public void copy(ProductInfo source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -0,0 +1,12 @@
package me.zhengjie.modules.wms.bd.repository;
import me.zhengjie.modules.wms.bd.domain.MaterialInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author
* @date 2019-07-27
*/
public interface MaterialInfoRepository extends JpaRepository<MaterialInfo, Integer>, JpaSpecificationExecutor {
}

View File

@ -0,0 +1,12 @@
package me.zhengjie.modules.wms.bd.repository;
import me.zhengjie.modules.wms.bd.domain.ProductInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author
* @date 2019-07-27
*/
public interface ProductInfoRepository extends JpaRepository<ProductInfo, Integer>, JpaSpecificationExecutor {
}

View File

@ -0,0 +1,61 @@
package me.zhengjie.modules.wms.bd.rest;
import me.zhengjie.aop.log.Log;
import me.zhengjie.modules.wms.bd.domain.MaterialInfo;
import me.zhengjie.modules.wms.bd.service.MaterialInfoService;
import me.zhengjie.modules.wms.bd.service.dto.MaterialInfoQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
/**
* @author
* @date 2019-07-27
*/
@Api(tags = "BdMaterialInfo管理")
@RestController
@RequestMapping("api")
public class MaterialInfoController {
@Autowired
private MaterialInfoService materialInfoService;
@Log("查询物料资料")
@ApiOperation(value = "查询物料资料")
@GetMapping(value = "/materialInfo")
@PreAuthorize("hasAnyRole('ADMIN','BDMATERIALINFO_ALL','BDMATERIALINFO_SELECT')")
public ResponseEntity getBdMaterialInfos(MaterialInfoQueryCriteria criteria, Pageable pageable){
return new ResponseEntity(materialInfoService.queryAll(criteria,pageable),HttpStatus.OK);
}
@Log("新增物料资料")
@ApiOperation(value = "新增物料资料")
@PostMapping(value = "/materialInfo")
@PreAuthorize("hasAnyRole('ADMIN','BDMATERIALINFO_ALL','BDMATERIALINFO_CREATE')")
public ResponseEntity create(@Validated @RequestBody MaterialInfo resources){
return new ResponseEntity(materialInfoService.create(resources),HttpStatus.CREATED);
}
@Log("修改物料资料")
@ApiOperation(value = "修改物料资料")
@PutMapping(value = "/materialInfo")
@PreAuthorize("hasAnyRole('ADMIN','BDMATERIALINFO_ALL','BDMATERIALINFO_EDIT')")
public ResponseEntity update(@Validated @RequestBody MaterialInfo resources){
materialInfoService.update(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT);
}
@Log("删除物料资料")
@ApiOperation(value = "删除物料资料")
@DeleteMapping(value = "/materialInfo/{id}")
@PreAuthorize("hasAnyRole('ADMIN','BDMATERIALINFO_ALL','BDMATERIALINFO_DELETE')")
public ResponseEntity delete(@PathVariable Integer id){
materialInfoService.delete(id);
return new ResponseEntity(HttpStatus.OK);
}
}

View File

@ -0,0 +1,61 @@
package me.zhengjie.modules.wms.bd.rest;
import me.zhengjie.aop.log.Log;
import me.zhengjie.modules.wms.bd.domain.ProductInfo;
import me.zhengjie.modules.wms.bd.service.ProductInfoService;
import me.zhengjie.modules.wms.bd.service.dto.ProductInfoQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
/**
* @author
* @date 2019-07-27
*/
@Api(tags = "BdProductInfo管理")
@RestController
@RequestMapping("api")
public class ProductInfoController {
@Autowired
private ProductInfoService productInfoService;
@Log("查询BdProductInfo")
@ApiOperation(value = "查询BdProductInfo")
@GetMapping(value = "/bdProductInfo")
@PreAuthorize("hasAnyRole('ADMIN','BDPRODUCTINFO_ALL','BDPRODUCTINFO_SELECT')")
public ResponseEntity getBdProductInfos(ProductInfoQueryCriteria criteria, Pageable pageable){
return new ResponseEntity(productInfoService.queryAll(criteria,pageable),HttpStatus.OK);
}
@Log("新增BdProductInfo")
@ApiOperation(value = "新增BdProductInfo")
@PostMapping(value = "/bdProductInfo")
@PreAuthorize("hasAnyRole('ADMIN','BDPRODUCTINFO_ALL','BDPRODUCTINFO_CREATE')")
public ResponseEntity create(@Validated @RequestBody ProductInfo resources){
return new ResponseEntity(productInfoService.create(resources),HttpStatus.CREATED);
}
@Log("修改BdProductInfo")
@ApiOperation(value = "修改BdProductInfo")
@PutMapping(value = "/bdProductInfo")
@PreAuthorize("hasAnyRole('ADMIN','BDPRODUCTINFO_ALL','BDPRODUCTINFO_EDIT')")
public ResponseEntity update(@Validated @RequestBody ProductInfo resources){
productInfoService.update(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT);
}
@Log("删除BdProductInfo")
@ApiOperation(value = "删除BdProductInfo")
@DeleteMapping(value = "/bdProductInfo/{id}")
@PreAuthorize("hasAnyRole('ADMIN','BDPRODUCTINFO_ALL','BDPRODUCTINFO_DELETE')")
public ResponseEntity delete(@PathVariable Integer id){
productInfoService.delete(id);
return new ResponseEntity(HttpStatus.OK);
}
}

View File

@ -0,0 +1,64 @@
package me.zhengjie.modules.wms.bd.service;
import me.zhengjie.modules.wms.bd.domain.MaterialInfo;
import me.zhengjie.modules.wms.bd.service.dto.MaterialInfoDTO;
import me.zhengjie.modules.wms.bd.service.dto.MaterialInfoQueryCriteria;
//import org.springframework.cache.annotation.CacheConfig;
//import org.springframework.cache.annotation.CacheEvict;
//import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Pageable;
/**
* @author
* @date 2019-07-27
*/
//@CacheConfig(cacheNames = "bdMaterialInfo")
public interface MaterialInfoService {
/**
* queryAll
* @param criteria
* @param pageable
* @return
*/
//@Cacheable(keyGenerator = "keyGenerator")
Object queryAll(MaterialInfoQueryCriteria criteria, Pageable pageable);
/**
* queryAll
* @param criteria
* @return
*/
//@Cacheable(keyGenerator = "keyGenerator")
public Object queryAll(MaterialInfoQueryCriteria criteria);
/**
* findById
* @param id
* @return
*/
//@Cacheable(key = "#p0")
MaterialInfoDTO findById(Integer id);
/**
* create
* @param resources
* @return
*/
//@CacheEvict(allEntries = true)
MaterialInfoDTO create(MaterialInfo resources);
/**
* update
* @param resources
*/
//@CacheEvict(allEntries = true)
void update(MaterialInfo resources);
/**
* delete
* @param id
*/
//@CacheEvict(allEntries = true)
void delete(Integer id);
}

View File

@ -0,0 +1,64 @@
package me.zhengjie.modules.wms.bd.service;
import me.zhengjie.modules.wms.bd.domain.ProductInfo;
import me.zhengjie.modules.wms.bd.service.dto.ProductInfoDTO;
import me.zhengjie.modules.wms.bd.service.dto.ProductInfoQueryCriteria;
//import org.springframework.cache.annotation.CacheConfig;
//import org.springframework.cache.annotation.CacheEvict;
//import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Pageable;
/**
* @author
* @date 2019-07-27
*/
//@CacheConfig(cacheNames = "bdProductInfo")
public interface ProductInfoService {
/**
* queryAll
* @param criteria
* @param pageable
* @return
*/
//@Cacheable(keyGenerator = "keyGenerator")
Object queryAll(ProductInfoQueryCriteria criteria, Pageable pageable);
/**
* queryAll
* @param criteria
* @return
*/
//@Cacheable(keyGenerator = "keyGenerator")
public Object queryAll(ProductInfoQueryCriteria criteria);
/**
* findById
* @param id
* @return
*/
//@Cacheable(key = "#p0")
ProductInfoDTO findById(Integer id);
/**
* create
* @param resources
* @return
*/
//@CacheEvict(allEntries = true)
ProductInfoDTO create(ProductInfo resources);
/**
* update
* @param resources
*/
//@CacheEvict(allEntries = true)
void update(ProductInfo resources);
/**
* delete
* @param id
*/
//@CacheEvict(allEntries = true)
void delete(Integer id);
}

View File

@ -0,0 +1,54 @@
package me.zhengjie.modules.wms.bd.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @author
* @date 2019-07-27
*/
@Data
public class MaterialInfoDTO implements Serializable {
// 主键
private Integer id;
// 所属物料分类主键
private Integer materialCategoryId;
// 物料分类名称
private String materialCategoryName;
// 物料名称
private String name;
// 物料规格
private String specifications;
// 所属计量单位主键
private Integer measureUnitId;
// 所属计量单位名称
private String measureUnitName;
// 产品库存预警[{“sort”:””,”ware_house_code”:””,”ware_house_name”:””,”minimum_inventory”:””,”highest_inventory”:””}]
private String materialInventoryWarning;
// 产品期初设置[{“sort”:””,”ware_house_code”:””,”ware_house_name”:””,“initial_setup_numer”:””,“initial_setup_total_price”:””}]
private String materialInitialSetup;
// 物料期初合计期初总价格
private Integer materialInitialSetupTotalPrice;
// 物料期初合计总数量
private String materialInitialSetupTotalNumber;
// 创建时间
private Timestamp createTime;
// 更新时间
private Timestamp updateTime;
}

View File

@ -0,0 +1,13 @@
package me.zhengjie.modules.wms.bd.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import me.zhengjie.annotation.Query;
/**
* @author
* @date 2019-07-27
*/
@Data
public class MaterialInfoQueryCriteria {
}

View File

@ -0,0 +1,67 @@
package me.zhengjie.modules.wms.bd.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @author
* @date 2019-07-27
*/
@Data
public class ProductInfoDTO implements Serializable {
// 主键
private Integer id;
// 所属产品分类
private Integer productCategoryId;
// 产品分类名称
private String productCategoryName;
// 产品编号
private String productCode;
// 产品名称
private String name;
// 产品规格
private String specifications;
// 所属计量单位主键
private Integer measureUnitId;
// 所属计量单位名称
private String measureUnitName;
// 产品单价(保留两位小数) 单位:元
private Integer unitPrice;
// 产品库存预警[{“sort”:1,”ware_house_code”:””,”ware_house_name”:””,”minimum_inventory”:””,”highest_inventory”:””}]
private String productInventoryWarning;
// 产品期初设置
[ {
sort:,
ware_house_code:,
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 Timestamp createTime;
// 更新时间
private Timestamp updateTime;
}

View File

@ -0,0 +1,13 @@
package me.zhengjie.modules.wms.bd.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import me.zhengjie.annotation.Query;
/**
* @author
* @date 2019-07-27
*/
@Data
public class ProductInfoQueryCriteria {
}

View File

@ -0,0 +1,73 @@
package me.zhengjie.modules.wms.bd.service.impl;
import me.zhengjie.modules.wms.bd.domain.MaterialInfo;
import me.zhengjie.utils.ValidationUtil;
import me.zhengjie.modules.wms.bd.repository.MaterialInfoRepository;
import me.zhengjie.modules.wms.bd.service.MaterialInfoService;
import me.zhengjie.modules.wms.bd.service.dto.MaterialInfoDTO;
import me.zhengjie.modules.wms.bd.service.dto.MaterialInfoQueryCriteria;
import me.zhengjie.modules.wms.bd.service.mapper.MaterialInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp;
/**
* @author
* @date 2019-07-27
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class MaterialInfoServiceImpl implements MaterialInfoService {
@Autowired
private MaterialInfoRepository materialInfoRepository;
@Autowired
private MaterialInfoMapper materialInfoMapper;
@Override
public Object queryAll(MaterialInfoQueryCriteria criteria, Pageable pageable){
Page<MaterialInfo> page = materialInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(materialInfoMapper::toDto));
}
@Override
public Object queryAll(MaterialInfoQueryCriteria criteria){
return materialInfoMapper.toDto(materialInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
public MaterialInfoDTO findById(Integer id) {
Optional<MaterialInfo> bdMaterialInfo = materialInfoRepository.findById(id);
ValidationUtil.isNull(bdMaterialInfo,"BdMaterialInfo","id",id);
return materialInfoMapper.toDto(bdMaterialInfo.get());
}
@Override
@Transactional(rollbackFor = Exception.class)
public MaterialInfoDTO create(MaterialInfo resources) {
return materialInfoMapper.toDto(materialInfoRepository.save(resources));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(MaterialInfo resources) {
Optional<MaterialInfo> optionalBdMaterialInfo = materialInfoRepository.findById(resources.getId());
ValidationUtil.isNull( optionalBdMaterialInfo,"BdMaterialInfo","id",resources.getId());
MaterialInfo materialInfo = optionalBdMaterialInfo.get();
materialInfo.copy(resources);
materialInfoRepository.save(materialInfo);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Integer id) {
materialInfoRepository.deleteById(id);
}
}

View File

@ -0,0 +1,73 @@
package me.zhengjie.modules.wms.bd.service.impl;
import me.zhengjie.modules.wms.bd.domain.ProductInfo;
import me.zhengjie.utils.ValidationUtil;
import me.zhengjie.modules.wms.bd.repository.ProductInfoRepository;
import me.zhengjie.modules.wms.bd.service.ProductInfoService;
import me.zhengjie.modules.wms.bd.service.dto.ProductInfoDTO;
import me.zhengjie.modules.wms.bd.service.dto.ProductInfoQueryCriteria;
import me.zhengjie.modules.wms.bd.service.mapper.ProductInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp;
/**
* @author
* @date 2019-07-27
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class ProductInfoServiceImpl implements ProductInfoService {
@Autowired
private ProductInfoRepository productInfoRepository;
@Autowired
private ProductInfoMapper productInfoMapper;
@Override
public Object queryAll(ProductInfoQueryCriteria criteria, Pageable pageable){
Page<ProductInfo> page = productInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(productInfoMapper::toDto));
}
@Override
public Object queryAll(ProductInfoQueryCriteria criteria){
return productInfoMapper.toDto(productInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
public ProductInfoDTO findById(Integer id) {
Optional<ProductInfo> bdProductInfo = productInfoRepository.findById(id);
ValidationUtil.isNull(bdProductInfo,"BdProductInfo","id",id);
return productInfoMapper.toDto(bdProductInfo.get());
}
@Override
@Transactional(rollbackFor = Exception.class)
public ProductInfoDTO create(ProductInfo resources) {
return productInfoMapper.toDto(productInfoRepository.save(resources));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(ProductInfo resources) {
Optional<ProductInfo> optionalBdProductInfo = productInfoRepository.findById(resources.getId());
ValidationUtil.isNull( optionalBdProductInfo,"BdProductInfo","id",resources.getId());
ProductInfo productInfo = optionalBdProductInfo.get();
productInfo.copy(resources);
productInfoRepository.save(productInfo);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Integer id) {
productInfoRepository.deleteById(id);
}
}

View File

@ -0,0 +1,16 @@
package me.zhengjie.modules.wms.bd.service.mapper;
import me.zhengjie.mapper.EntityMapper;
import me.zhengjie.modules.wms.bd.domain.MaterialInfo;
import me.zhengjie.modules.wms.bd.service.dto.MaterialInfoDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author
* @date 2019-07-27
*/
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface MaterialInfoMapper extends EntityMapper<MaterialInfoDTO, MaterialInfo> {
}

View File

@ -0,0 +1,16 @@
package me.zhengjie.modules.wms.bd.service.mapper;
import me.zhengjie.mapper.EntityMapper;
import me.zhengjie.modules.wms.bd.domain.ProductInfo;
import me.zhengjie.modules.wms.bd.service.dto.ProductInfoDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author
* @date 2019-07-27
*/
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface ProductInfoMapper extends EntityMapper<ProductInfoDTO, ProductInfo> {
}