发货单

pull/451/head
starrysky 2019-08-29 18:02:17 +08:00
parent 3b78ebb4c5
commit 6f46a259f4
10 changed files with 322 additions and 1 deletions

View File

@ -3,6 +3,8 @@ package me.zhengjie.modules.wms.customerOrder.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;
@ -83,10 +85,12 @@ public class CustomerOrder 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;
// 总额 // 总额

View File

@ -0,0 +1,46 @@
package me.zhengjie.modules.wms.sr.productCount.domain;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @author jie
* @date 2019-08-29
*/
@Entity
@Data
@Table(name="sr_product_count")
public class ProductCount implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "product_id")
private Long productId;
@Column(name = "product_name")
private String productName;
@Column(name = "total_number")
private Long totalNumber;
@Column(name = "gmt_create")
@CreationTimestamp
private Timestamp gmtCreate;
@Column(name = "gmt_update")
@CreationTimestamp
private Timestamp gmtUpdate;
public void copy(ProductCount source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -0,0 +1,12 @@
package me.zhengjie.modules.wms.sr.productCount.repository;
import me.zhengjie.modules.wms.sr.productCount.domain.ProductCount;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author jie
* @date 2019-08-29
*/
public interface ProductCountRepository extends JpaRepository<ProductCount, Long>, JpaSpecificationExecutor {
}

View File

@ -0,0 +1,67 @@
package me.zhengjie.modules.wms.sr.productCount.rest;
import me.zhengjie.aop.log.Log;
import me.zhengjie.modules.wms.sr.productCount.domain.ProductCount;
import me.zhengjie.modules.wms.sr.productCount.service.ProductCountService;
import me.zhengjie.modules.wms.sr.productCount.service.dto.ProductCountQueryCriteria;
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 jie
* @date 2019-08-29
*/
@Api(tags = "产品统计管理")
@RestController
@RequestMapping("api")
public class ProductCountController {
@Autowired
private ProductCountService productCountService;
@Log("分页查询产品统计列表")
@ApiOperation(value = "分页查询产品统计列表")
@GetMapping(value = "/queryProductCountPage")
@PreAuthorize("hasAnyRole('ADMIN','SRPRODUCTCOUNT_ALL','SRPRODUCTCOUNT_SELECT')")
public ResponseEntity queryProductCountPage(ProductCountQueryCriteria criteria, Pageable pageable){
return new ResponseEntity(productCountService.queryAll(criteria,pageable),HttpStatus.OK);
}
@Log("新增产品统计")
@ApiOperation(value = "新增产品统计")
@PostMapping(value = "/productCount")
@PreAuthorize("hasAnyRole('ADMIN','SRPRODUCTCOUNT_ALL','SRPRODUCTCOUNT_CREATE')")
public ResponseEntity create(@RequestBody ProductCount resources){
return new ResponseEntity(productCountService.create(resources),HttpStatus.CREATED);
}
@Log("修改产品统计")
@ApiOperation(value = "修改产品统计")
@PutMapping(value = "/productCount")
@PreAuthorize("hasAnyRole('ADMIN','SRPRODUCTCOUNT_ALL','SRPRODUCTCOUNT_EDIT')")
public ResponseEntity update(@RequestBody ProductCount resources){
productCountService.update(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT);
}
@Log("删除产品统计")
@ApiOperation(value = "删除产品统计")
@DeleteMapping(value = "/productCount/{id}")
@PreAuthorize("hasAnyRole('ADMIN','SRPRODUCTCOUNT_ALL','SRPRODUCTCOUNT_DELETE')")
public ResponseEntity delete(@PathVariable Long id){
productCountService.delete(id);
return new ResponseEntity(HttpStatus.OK);
}
@Log("查看产品统计详情")
@GetMapping(value = "/productCount/{id}")
public ResponseEntity getProductCountInfo(@PathVariable Long id){
return new ResponseEntity(productCountService.findById(id), HttpStatus.OK);
}
}

View File

@ -0,0 +1,64 @@
package me.zhengjie.modules.wms.sr.productCount.service;
import me.zhengjie.modules.wms.sr.productCount.domain.ProductCount;
import me.zhengjie.modules.wms.sr.productCount.service.dto.ProductCountDTO;
import me.zhengjie.modules.wms.sr.productCount.service.dto.ProductCountQueryCriteria;
//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 jie
* @date 2019-08-29
*/
//@CacheConfig(cacheNames = "srProductCount")
public interface ProductCountService {
/**
* queryAll
* @param criteria
* @param pageable
* @return
*/
//@Cacheable(keyGenerator = "keyGenerator")
Object queryAll(ProductCountQueryCriteria criteria, Pageable pageable);
/**
* queryAll
* @param criteria
* @return
*/
//@Cacheable(keyGenerator = "keyGenerator")
public Object queryAll(ProductCountQueryCriteria criteria);
/**
* findById
* @param id
* @return
*/
//@Cacheable(key = "#p0")
ProductCountDTO findById(Long id);
/**
* create
* @param resources
* @return
*/
//@CacheEvict(allEntries = true)
ProductCountDTO create(ProductCount resources);
/**
* update
* @param resources
*/
//@CacheEvict(allEntries = true)
void update(ProductCount resources);
/**
* delete
* @param id
*/
//@CacheEvict(allEntries = true)
void delete(Long id);
}

View File

@ -0,0 +1,26 @@
package me.zhengjie.modules.wms.sr.productCount.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @author jie
* @date 2019-08-29
*/
@Data
public class ProductCountDTO implements Serializable {
private Long id;
private Long productId;
private String productName;
private Long totalNumber;
private Timestamp gmtCreate;
private Timestamp gmtUpdate;
}

View File

@ -0,0 +1,13 @@
package me.zhengjie.modules.wms.sr.productCount.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import me.zhengjie.annotation.Query;
/**
* @author jie
* @date 2019-08-29
*/
@Data
public class ProductCountQueryCriteria {
}

View File

@ -0,0 +1,73 @@
package me.zhengjie.modules.wms.sr.productCount.service.impl;
import me.zhengjie.modules.wms.sr.productCount.domain.ProductCount;
import me.zhengjie.utils.ValidationUtil;
import me.zhengjie.modules.wms.sr.productCount.repository.ProductCountRepository;
import me.zhengjie.modules.wms.sr.productCount.service.ProductCountService;
import me.zhengjie.modules.wms.sr.productCount.service.dto.ProductCountDTO;
import me.zhengjie.modules.wms.sr.productCount.service.dto.ProductCountQueryCriteria;
import me.zhengjie.modules.wms.sr.productCount.service.mapper.ProductCountMapper;
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 jie
* @date 2019-08-29
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class ProductCountServiceImpl implements ProductCountService {
@Autowired
private ProductCountRepository productCountRepository;
@Autowired
private ProductCountMapper productCountMapper;
@Override
public Object queryAll(ProductCountQueryCriteria criteria, Pageable pageable){
Page<ProductCount> page = productCountRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(productCountMapper::toDto));
}
@Override
public Object queryAll(ProductCountQueryCriteria criteria){
return productCountMapper.toDto(productCountRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
public ProductCountDTO findById(Long id) {
Optional<ProductCount> srProductCount = productCountRepository.findById(id);
ValidationUtil.isNull(srProductCount,"SrProductCount","id",id);
return productCountMapper.toDto(srProductCount.get());
}
@Override
@Transactional(rollbackFor = Exception.class)
public ProductCountDTO create(ProductCount resources) {
return productCountMapper.toDto(productCountRepository.save(resources));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(ProductCount resources) {
Optional<ProductCount> optionalSrProductCount = productCountRepository.findById(resources.getId());
ValidationUtil.isNull( optionalSrProductCount,"SrProductCount","id",resources.getId());
ProductCount productCount = optionalSrProductCount.get();
productCount.copy(resources);
productCountRepository.save(productCount);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
productCountRepository.deleteById(id);
}
}

View File

@ -0,0 +1,16 @@
package me.zhengjie.modules.wms.sr.productCount.service.mapper;
import me.zhengjie.mapper.EntityMapper;
import me.zhengjie.modules.wms.sr.productCount.domain.ProductCount;
import me.zhengjie.modules.wms.sr.productCount.service.dto.ProductCountDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author jie
* @date 2019-08-29
*/
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface ProductCountMapper extends EntityMapper<ProductCountDTO, ProductCount> {
}

View File

@ -3,7 +3,7 @@ server:
spring: spring:
profiles: profiles:
active: prod active: dev
jackson: jackson:
time-zone: GMT+8 time-zone: GMT+8
data: data: