新增委外验收单

pull/451/head
starrysky 2019-10-06 01:23:00 +08:00
parent 750a625434
commit f90fae0fd2
12 changed files with 241 additions and 19 deletions

View File

@ -8,6 +8,7 @@ import java.sql.Timestamp;
import java.io.Serializable;
/**
*
* @author jie
* @date 2019-10-01
*/
@ -29,7 +30,7 @@ public class OutSourceInspectionCertificate implements Serializable {
private Timestamp updateTime;
@Column(name = "status")
private Integer status;
private Boolean status;
// 所属委外加工单
@Column(name = "out_source_process_sheet_id")

View File

@ -29,7 +29,7 @@ public class OutSourceInspectionCertificateProduct implements Serializable {
private Timestamp updateTime;
@Column(name = "status")
private Integer status;
private Boolean status;
// 所属委外验收单
@Column(name = "out_source_inspection_certificate_id")

View File

@ -1,12 +1,29 @@
package me.zhengjie.modules.wms.outSourceProductSheet.repository;
import me.zhengjie.modules.wms.outSourceProductSheet.domain.OutSourceInspectionCertificateProduct;
import me.zhengjie.modules.wms.outSourceProductSheet.domain.OutSourceProcessSheetProduct;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
/**
* @author jie
* @date 2019-10-01
*/
public interface OutSourceInspectionCertificateProductRepository extends JpaRepository<OutSourceInspectionCertificateProduct, Long>, JpaSpecificationExecutor {
/**
* true
* @param outSourceInspectionCertificateId
* @return
*/
@Query(value ="select * from s_out_source_inspection_certificate_product where out_source_inspection_certificate_id = ?1 and status =1", nativeQuery = true)
List<OutSourceInspectionCertificateProduct> queryByOutSourceInspectionCertificateIdAndStatusTrue(Long outSourceInspectionCertificateId);
@Modifying
@Query(value = "delete s_out_source_inspection_certificate_product where product_code = ?1 and out_source_inspection_certificate_id = ?2", nativeQuery = true)
void deleteByProductCodeAndOutSourceInspectionCertificateId(String productCode, Long outSourceInspectionCertificateId);
}

View File

@ -1,12 +1,21 @@
package me.zhengjie.modules.wms.outSourceProductSheet.repository;
import me.zhengjie.modules.wms.outSourceProductSheet.domain.OutSourceInspectionCertificate;
import me.zhengjie.modules.wms.outSourceProductSheet.domain.OutSourceProcessSheet;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
/**
* @author jie
* @date 2019-10-01
*/
public interface OutSourceInspectionCertificateRepository extends JpaRepository<OutSourceInspectionCertificate, Long>, JpaSpecificationExecutor {
/**
*
* @param outSourceInspectionCertificateCode
* @return
*/
@Query(value ="select * from s_out_source_inspection_certificate where out_source_inspection_certificate_code = ?1 and status = 1", nativeQuery = true)
OutSourceInspectionCertificate findByOutSourceInspectionCertificateCode(String outSourceInspectionCertificateCode);
}

View File

@ -0,0 +1,39 @@
package me.zhengjie.modules.wms.outSourceProductSheet.request;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;
/**
* @author jie
* @date 2019-10-01
*/
@Data
public class CreateOutSourceInspectionCertificateRequest implements Serializable {
// 所属委外加工单
private Long outSourceProcessSheetId;
// 制单人
private Long makePeopleId;
// 制单人姓名
private String makePeopleName;
// 委外加工验收单单据编号
private String outSourceInspectionCertificateCode;
private String remark;
private List<OutSourceInspectionCertificateProductRequest> outSourceInspectionCertificateProductList;
public void copy(CreateOutSourceInspectionCertificateRequest source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -0,0 +1,37 @@
package me.zhengjie.modules.wms.outSourceProductSheet.request;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author jie
* @date 2019-10-01
*/
@Data
public class OutSourceInspectionCertificateProductRequest implements Serializable {
// 所属委外验收单
@Column(name = "out_source_inspection_certificate_id")
private Long outSourceInspectionCertificateId;
@Column(name = "product_code")
private String productCode;
@Column(name = "product_id")
private Long productId;
@Column(name = "product_name")
private String productName;
@Column(name = "remark")
private String remark;
public void copy(OutSourceInspectionCertificateProductRequest source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -2,6 +2,7 @@ package me.zhengjie.modules.wms.outSourceProductSheet.rest;
import me.zhengjie.aop.log.Log;
import me.zhengjie.modules.wms.outSourceProductSheet.domain.OutSourceInspectionCertificate;
import me.zhengjie.modules.wms.outSourceProductSheet.request.CreateOutSourceInspectionCertificateRequest;
import me.zhengjie.modules.wms.outSourceProductSheet.service.OutSourceInspectionCertificateService;
import me.zhengjie.modules.wms.outSourceProductSheet.service.dto.OutSourceInspectionCertificateQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
@ -37,8 +38,8 @@ public class OutSourceInspectionCertificateController {
@ApiOperation(value = "新增委外验收单")
@PostMapping(value = "/outSourceInspectionCertificate")
@PreAuthorize("hasAnyRole('ADMIN','SOUTSOURCEINSPECTIONCERTIFICATE_ALL','SOUTSOURCEINSPECTIONCERTIFICATE_CREATE')")
public ResponseEntity create(@Validated @RequestBody OutSourceInspectionCertificate resources){
return new ResponseEntity(outSourceInspectionCertificateService.create(resources),HttpStatus.CREATED);
public ResponseEntity create(@Validated @RequestBody CreateOutSourceInspectionCertificateRequest createOutSourceInspectionCertificateRequest){
return new ResponseEntity(outSourceInspectionCertificateService.create(createOutSourceInspectionCertificateRequest),HttpStatus.CREATED);
}
@Log("修改委外验收单")

View File

@ -1,6 +1,7 @@
package me.zhengjie.modules.wms.outSourceProductSheet.service;
import me.zhengjie.modules.wms.outSourceProductSheet.domain.OutSourceInspectionCertificate;
import me.zhengjie.modules.wms.outSourceProductSheet.request.CreateOutSourceInspectionCertificateRequest;
import me.zhengjie.modules.wms.outSourceProductSheet.service.dto.OutSourceInspectionCertificateDTO;
import me.zhengjie.modules.wms.outSourceProductSheet.service.dto.OutSourceInspectionCertificateQueryCriteria;
//import org.springframework.cache.annotation.CacheConfig;
@ -42,11 +43,11 @@ public interface OutSourceInspectionCertificateService {
/**
* create
* @param resources
* @param createOutSourceInspectionCertificateRequest
* @return
*/
//@CacheEvict(allEntries = true)
OutSourceInspectionCertificateDTO create(OutSourceInspectionCertificate resources);
OutSourceInspectionCertificateDTO create(CreateOutSourceInspectionCertificateRequest createOutSourceInspectionCertificateRequest);
/**
* update

View File

@ -3,9 +3,11 @@ package me.zhengjie.modules.wms.outSourceProductSheet.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.io.Serializable;
import java.util.List;
/**
*
* @author jie
* @date 2019-10-01
*/
@ -34,4 +36,7 @@ public class OutSourceInspectionCertificateDTO implements Serializable {
private String outSourceInspectionCertificateCode;
private String remark;
// 委外验收单产品信息
private List<OutSourceInspectionCertificateProductDTO> outSourceInspectionCertificateDTOList;
}

View File

@ -6,6 +6,7 @@ import java.io.Serializable;
/**
* 寿
* @author jie
* @date 2019-10-01
*/

View File

@ -1,21 +1,42 @@
package me.zhengjie.modules.wms.outSourceProductSheet.service.impl;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.wms.outSourceProductSheet.domain.OutSourceInspectionCertificate;
import me.zhengjie.modules.wms.outSourceProductSheet.domain.OutSourceInspectionCertificateProduct;
import me.zhengjie.modules.wms.outSourceProductSheet.domain.OutSourceProcessSheet;
import me.zhengjie.modules.wms.outSourceProductSheet.domain.OutSourceProcessSheetProduct;
import me.zhengjie.modules.wms.outSourceProductSheet.repository.OutSourceInspectionCertificateProductRepository;
import me.zhengjie.modules.wms.outSourceProductSheet.request.CreateOutSourceInspectionCertificateRequest;
import me.zhengjie.modules.wms.outSourceProductSheet.request.CreateOutSourceProcessSheetRequest;
import me.zhengjie.modules.wms.outSourceProductSheet.request.OutSourceInspectionCertificateProductRequest;
import me.zhengjie.modules.wms.outSourceProductSheet.request.OutSourceProcessSheetProductRequest;
import me.zhengjie.modules.wms.outSourceProductSheet.service.dto.*;
import me.zhengjie.modules.wms.outSourceProductSheet.service.mapper.OutSourceInspectionCertificateProductMapper;
import me.zhengjie.utils.ValidationUtil;
import me.zhengjie.modules.wms.outSourceProductSheet.repository.OutSourceInspectionCertificateRepository;
import me.zhengjie.modules.wms.outSourceProductSheet.service.OutSourceInspectionCertificateService;
import me.zhengjie.modules.wms.outSourceProductSheet.service.dto.OutSourceInspectionCertificateDTO;
import me.zhengjie.modules.wms.outSourceProductSheet.service.dto.OutSourceInspectionCertificateQueryCriteria;
import me.zhengjie.modules.wms.outSourceProductSheet.service.mapper.OutSourceInspectionCertificateMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
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;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
/**
* @author jie
@ -31,28 +52,117 @@ public class OutSourceInspectionCertificateServiceImpl implements OutSourceInspe
@Autowired
private OutSourceInspectionCertificateMapper outSourceInspectionCertificateMapper;
@Autowired
private OutSourceInspectionCertificateProductRepository outSourceInspectionCertificateProductRepository;
@Autowired
private OutSourceInspectionCertificateProductMapper outSourceInspectionCertificateProductMapper;
@Override
public Object queryAll(OutSourceInspectionCertificateQueryCriteria criteria, Pageable pageable){
Page<OutSourceInspectionCertificate> page = outSourceInspectionCertificateRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
Specification<OutSourceInspectionCertificate> specification = new Specification<OutSourceInspectionCertificate>() {
@Override
public Predicate toPredicate(Root<OutSourceInspectionCertificate> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
List<Predicate> targetPredicateList = new ArrayList<>();
Predicate statusPredicate = criteriaBuilder.equal(root.get("status"), 1);
targetPredicateList.add(statusPredicate);
if(CollectionUtils.isEmpty(targetPredicateList)){
return null;
}else{
return criteriaBuilder.and(targetPredicateList.toArray(new Predicate[targetPredicateList.size()]));
}
}
};
Page<OutSourceInspectionCertificate> page = outSourceInspectionCertificateRepository.findAll(specification,pageable);
return PageUtil.toPage(page.map(outSourceInspectionCertificateMapper::toDto));
}
@Override
public Object queryAll(OutSourceInspectionCertificateQueryCriteria criteria){
return outSourceInspectionCertificateMapper.toDto(outSourceInspectionCertificateRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
Specification<OutSourceInspectionCertificate> specification = new Specification<OutSourceInspectionCertificate>() {
@Override
public Predicate toPredicate(Root<OutSourceInspectionCertificate> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
List<Predicate> targetPredicateList = new ArrayList<>();
Predicate statusPredicate = criteriaBuilder.equal(root.get("status"), 1);
targetPredicateList.add(statusPredicate);
if(CollectionUtils.isEmpty(targetPredicateList)){
return null;
}else{
return criteriaBuilder.and(targetPredicateList.toArray(new Predicate[targetPredicateList.size()]));
}
}
};
return outSourceInspectionCertificateMapper.toDto(outSourceInspectionCertificateRepository.findAll(specification));
}
@Override
public OutSourceInspectionCertificateDTO findById(Long id) {
Optional<OutSourceInspectionCertificate> sOutSourceInspectionCertificate = outSourceInspectionCertificateRepository.findById(id);
ValidationUtil.isNull(sOutSourceInspectionCertificate,"SOutSourceInspectionCertificate","id",id);
return outSourceInspectionCertificateMapper.toDto(sOutSourceInspectionCertificate.get());
Optional<OutSourceInspectionCertificate> invoiceOptional = outSourceInspectionCertificateRepository.findById(id);
OutSourceInspectionCertificate outSourceInspectionCertificate = invoiceOptional.get();
OutSourceInspectionCertificateDTO outSourceInspectionCertificateDTO = outSourceInspectionCertificateMapper.toDto(outSourceInspectionCertificate);
List<OutSourceInspectionCertificateProduct> outSourceInspectionCertificateProductList = outSourceInspectionCertificateProductRepository.queryByOutSourceInspectionCertificateIdAndStatusTrue(id);
if(!CollectionUtils.isEmpty(outSourceInspectionCertificateProductList)){
List<OutSourceInspectionCertificateProductDTO> outSourceInspectionCertificateProductDTOList = outSourceInspectionCertificateProductMapper.toDto(outSourceInspectionCertificateProductList);
outSourceInspectionCertificateDTO.setOutSourceInspectionCertificateDTOList(outSourceInspectionCertificateProductDTOList);
}
return outSourceInspectionCertificateDTO;
}
@Override
@Transactional(rollbackFor = Exception.class)
public OutSourceInspectionCertificateDTO create(OutSourceInspectionCertificate resources) {
return outSourceInspectionCertificateMapper.toDto(outSourceInspectionCertificateRepository.save(resources));
public OutSourceInspectionCertificateDTO create(CreateOutSourceInspectionCertificateRequest createOutSourceInspectionCertificateRequest) {
OutSourceInspectionCertificate outSourceInspectionCertificate = new OutSourceInspectionCertificate();
BeanUtils.copyProperties(createOutSourceInspectionCertificateRequest, outSourceInspectionCertificate);
String outSourceInspectionCertificateCode = outSourceInspectionCertificate.getOutSourceInspectionCertificateCode();
if(!StringUtils.hasLength(outSourceInspectionCertificateCode)){
throw new BadRequestException("委外验收单单据编号不能为空!");
}
outSourceInspectionCertificate.setStatus(true);
// 新增委外验收单
outSourceInspectionCertificateRepository.save(outSourceInspectionCertificate);
outSourceInspectionCertificate = outSourceInspectionCertificateRepository.findByOutSourceInspectionCertificateCode(outSourceInspectionCertificateCode);
// 新增委外验收单产品信息
List<OutSourceInspectionCertificateProductRequest> outSourceInspectionCertificateProductRequestList = createOutSourceInspectionCertificateRequest.getOutSourceInspectionCertificateProductList();
if(CollectionUtils.isEmpty(outSourceInspectionCertificateProductRequestList)){
throw new BadRequestException("委外验收单产品信息不能为空!");
}
for(OutSourceInspectionCertificateProductRequest outSourceInspectionCertificateProductRequest : outSourceInspectionCertificateProductRequestList){
OutSourceInspectionCertificateProduct outSourceInspectionCertificateProduct = new OutSourceInspectionCertificateProduct();
BeanUtils.copyProperties(outSourceInspectionCertificateProductRequest, outSourceInspectionCertificateProduct);
outSourceInspectionCertificateProduct.setStatus(true);
outSourceInspectionCertificateProduct.setOutSourceInspectionCertificateId(outSourceInspectionCertificate.getId());
outSourceInspectionCertificateProductRepository.save(outSourceInspectionCertificateProduct);
}
OutSourceInspectionCertificateDTO outSourceInspectionCertificateDTO = outSourceInspectionCertificateMapper.toDto(outSourceInspectionCertificate);
List<OutSourceInspectionCertificateProduct> outSourceInspectionCertificateProductList = outSourceInspectionCertificateProductRepository.queryByOutSourceInspectionCertificateIdAndStatusTrue(outSourceInspectionCertificate.getId());
if(!CollectionUtils.isEmpty(outSourceInspectionCertificateProductList)){
List<OutSourceInspectionCertificateProductDTO> outSourceInspectionCertificateProductDTOList = new ArrayList<>();
for(OutSourceInspectionCertificateProduct outSourceInspectionCertificateProduct : outSourceInspectionCertificateProductList){
OutSourceInspectionCertificateProductDTO outSourceInspectionCertificateProductDTO = new OutSourceInspectionCertificateProductDTO();
BeanUtils.copyProperties(outSourceInspectionCertificateProduct, outSourceInspectionCertificateProductDTO);
outSourceInspectionCertificateProductDTOList.add(outSourceInspectionCertificateProductDTO);
}
outSourceInspectionCertificateDTO.setOutSourceInspectionCertificateDTOList(outSourceInspectionCertificateProductDTOList);
}
return outSourceInspectionCertificateDTO;
}
@Override

View File

@ -49,6 +49,7 @@ import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
/**
*
* @author jie
* @date 2019-08-17
*/
@ -70,9 +71,9 @@ public class OutSourceProcessSheetServiceImpl implements OutSourceProcessSheetSe
@Override
public Object queryAll(OutSourceProcessSheetQueryCriteria criteria, Pageable pageable){
Specification<OutSourceProcessSheetProduct> specification = new Specification<OutSourceProcessSheetProduct>() {
Specification<OutSourceProcessSheet> specification = new Specification<OutSourceProcessSheet>() {
@Override
public Predicate toPredicate(Root<OutSourceProcessSheetProduct> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
public Predicate toPredicate(Root<OutSourceProcessSheet> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
List<Predicate> targetPredicateList = new ArrayList<>();
@ -92,9 +93,9 @@ public class OutSourceProcessSheetServiceImpl implements OutSourceProcessSheetSe
@Override
public Object queryAll(OutSourceProcessSheetQueryCriteria criteria){
Specification<OutSourceProcessSheetProduct> specification = new Specification<OutSourceProcessSheetProduct>() {
Specification<OutSourceProcessSheet> specification = new Specification<OutSourceProcessSheet>() {
@Override
public Predicate toPredicate(Root<OutSourceProcessSheetProduct> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
public Predicate toPredicate(Root<OutSourceProcessSheet> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
List<Predicate> targetPredicateList = new ArrayList<>();