mirror of https://github.com/elunez/eladmin
新增委外验收单
parent
750a625434
commit
f90fae0fd2
|
@ -8,6 +8,7 @@ import java.sql.Timestamp;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 委外验收单实体类
|
||||||
* @author jie
|
* @author jie
|
||||||
* @date 2019-10-01
|
* @date 2019-10-01
|
||||||
*/
|
*/
|
||||||
|
@ -29,7 +30,7 @@ public class OutSourceInspectionCertificate implements Serializable {
|
||||||
private Timestamp updateTime;
|
private Timestamp updateTime;
|
||||||
|
|
||||||
@Column(name = "status")
|
@Column(name = "status")
|
||||||
private Integer status;
|
private Boolean status;
|
||||||
|
|
||||||
// 所属委外加工单
|
// 所属委外加工单
|
||||||
@Column(name = "out_source_process_sheet_id")
|
@Column(name = "out_source_process_sheet_id")
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class OutSourceInspectionCertificateProduct implements Serializable {
|
||||||
private Timestamp updateTime;
|
private Timestamp updateTime;
|
||||||
|
|
||||||
@Column(name = "status")
|
@Column(name = "status")
|
||||||
private Integer status;
|
private Boolean status;
|
||||||
|
|
||||||
// 所属委外验收单
|
// 所属委外验收单
|
||||||
@Column(name = "out_source_inspection_certificate_id")
|
@Column(name = "out_source_inspection_certificate_id")
|
||||||
|
|
|
@ -1,12 +1,29 @@
|
||||||
package me.zhengjie.modules.wms.outSourceProductSheet.repository;
|
package me.zhengjie.modules.wms.outSourceProductSheet.repository;
|
||||||
|
|
||||||
import me.zhengjie.modules.wms.outSourceProductSheet.domain.OutSourceInspectionCertificateProduct;
|
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.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
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
|
* @author jie
|
||||||
* @date 2019-10-01
|
* @date 2019-10-01
|
||||||
*/
|
*/
|
||||||
public interface OutSourceInspectionCertificateProductRepository extends JpaRepository<OutSourceInspectionCertificateProduct, Long>, JpaSpecificationExecutor {
|
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);
|
||||||
}
|
}
|
|
@ -1,12 +1,21 @@
|
||||||
package me.zhengjie.modules.wms.outSourceProductSheet.repository;
|
package me.zhengjie.modules.wms.outSourceProductSheet.repository;
|
||||||
|
|
||||||
import me.zhengjie.modules.wms.outSourceProductSheet.domain.OutSourceInspectionCertificate;
|
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.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author jie
|
||||||
* @date 2019-10-01
|
* @date 2019-10-01
|
||||||
*/
|
*/
|
||||||
public interface OutSourceInspectionCertificateRepository extends JpaRepository<OutSourceInspectionCertificate, Long>, JpaSpecificationExecutor {
|
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);
|
||||||
}
|
}
|
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package me.zhengjie.modules.wms.outSourceProductSheet.rest;
|
||||||
|
|
||||||
import me.zhengjie.aop.log.Log;
|
import me.zhengjie.aop.log.Log;
|
||||||
import me.zhengjie.modules.wms.outSourceProductSheet.domain.OutSourceInspectionCertificate;
|
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.OutSourceInspectionCertificateService;
|
||||||
import me.zhengjie.modules.wms.outSourceProductSheet.service.dto.OutSourceInspectionCertificateQueryCriteria;
|
import me.zhengjie.modules.wms.outSourceProductSheet.service.dto.OutSourceInspectionCertificateQueryCriteria;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -37,8 +38,8 @@ public class OutSourceInspectionCertificateController {
|
||||||
@ApiOperation(value = "新增委外验收单")
|
@ApiOperation(value = "新增委外验收单")
|
||||||
@PostMapping(value = "/outSourceInspectionCertificate")
|
@PostMapping(value = "/outSourceInspectionCertificate")
|
||||||
@PreAuthorize("hasAnyRole('ADMIN','SOUTSOURCEINSPECTIONCERTIFICATE_ALL','SOUTSOURCEINSPECTIONCERTIFICATE_CREATE')")
|
@PreAuthorize("hasAnyRole('ADMIN','SOUTSOURCEINSPECTIONCERTIFICATE_ALL','SOUTSOURCEINSPECTIONCERTIFICATE_CREATE')")
|
||||||
public ResponseEntity create(@Validated @RequestBody OutSourceInspectionCertificate resources){
|
public ResponseEntity create(@Validated @RequestBody CreateOutSourceInspectionCertificateRequest createOutSourceInspectionCertificateRequest){
|
||||||
return new ResponseEntity(outSourceInspectionCertificateService.create(resources),HttpStatus.CREATED);
|
return new ResponseEntity(outSourceInspectionCertificateService.create(createOutSourceInspectionCertificateRequest),HttpStatus.CREATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("修改委外验收单")
|
@Log("修改委外验收单")
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package me.zhengjie.modules.wms.outSourceProductSheet.service;
|
package me.zhengjie.modules.wms.outSourceProductSheet.service;
|
||||||
|
|
||||||
import me.zhengjie.modules.wms.outSourceProductSheet.domain.OutSourceInspectionCertificate;
|
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.OutSourceInspectionCertificateDTO;
|
||||||
import me.zhengjie.modules.wms.outSourceProductSheet.service.dto.OutSourceInspectionCertificateQueryCriteria;
|
import me.zhengjie.modules.wms.outSourceProductSheet.service.dto.OutSourceInspectionCertificateQueryCriteria;
|
||||||
//import org.springframework.cache.annotation.CacheConfig;
|
//import org.springframework.cache.annotation.CacheConfig;
|
||||||
|
@ -42,11 +43,11 @@ public interface OutSourceInspectionCertificateService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create
|
* create
|
||||||
* @param resources
|
* @param createOutSourceInspectionCertificateRequest
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
//@CacheEvict(allEntries = true)
|
//@CacheEvict(allEntries = true)
|
||||||
OutSourceInspectionCertificateDTO create(OutSourceInspectionCertificate resources);
|
OutSourceInspectionCertificateDTO create(CreateOutSourceInspectionCertificateRequest createOutSourceInspectionCertificateRequest);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* update
|
* update
|
||||||
|
|
|
@ -3,9 +3,11 @@ package me.zhengjie.modules.wms.outSourceProductSheet.service.dto;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 委外验收单信息
|
||||||
* @author jie
|
* @author jie
|
||||||
* @date 2019-10-01
|
* @date 2019-10-01
|
||||||
*/
|
*/
|
||||||
|
@ -34,4 +36,7 @@ public class OutSourceInspectionCertificateDTO implements Serializable {
|
||||||
private String outSourceInspectionCertificateCode;
|
private String outSourceInspectionCertificateCode;
|
||||||
|
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
// 委外验收单产品信息
|
||||||
|
private List<OutSourceInspectionCertificateProductDTO> outSourceInspectionCertificateDTOList;
|
||||||
}
|
}
|
|
@ -6,6 +6,7 @@ import java.io.Serializable;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 委外亚寿诞产品信息
|
||||||
* @author jie
|
* @author jie
|
||||||
* @date 2019-10-01
|
* @date 2019-10-01
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,21 +1,42 @@
|
||||||
package me.zhengjie.modules.wms.outSourceProductSheet.service.impl;
|
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.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.utils.ValidationUtil;
|
||||||
import me.zhengjie.modules.wms.outSourceProductSheet.repository.OutSourceInspectionCertificateRepository;
|
import me.zhengjie.modules.wms.outSourceProductSheet.repository.OutSourceInspectionCertificateRepository;
|
||||||
import me.zhengjie.modules.wms.outSourceProductSheet.service.OutSourceInspectionCertificateService;
|
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 me.zhengjie.modules.wms.outSourceProductSheet.service.mapper.OutSourceInspectionCertificateMapper;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Propagation;
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import org.springframework.data.domain.Page;
|
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.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
|
* @author jie
|
||||||
|
@ -31,28 +52,117 @@ public class OutSourceInspectionCertificateServiceImpl implements OutSourceInspe
|
||||||
@Autowired
|
@Autowired
|
||||||
private OutSourceInspectionCertificateMapper outSourceInspectionCertificateMapper;
|
private OutSourceInspectionCertificateMapper outSourceInspectionCertificateMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OutSourceInspectionCertificateProductRepository outSourceInspectionCertificateProductRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OutSourceInspectionCertificateProductMapper outSourceInspectionCertificateProductMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object queryAll(OutSourceInspectionCertificateQueryCriteria criteria, Pageable pageable){
|
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));
|
return PageUtil.toPage(page.map(outSourceInspectionCertificateMapper::toDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object queryAll(OutSourceInspectionCertificateQueryCriteria criteria){
|
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
|
@Override
|
||||||
public OutSourceInspectionCertificateDTO findById(Long id) {
|
public OutSourceInspectionCertificateDTO findById(Long id) {
|
||||||
Optional<OutSourceInspectionCertificate> sOutSourceInspectionCertificate = outSourceInspectionCertificateRepository.findById(id);
|
Optional<OutSourceInspectionCertificate> invoiceOptional = outSourceInspectionCertificateRepository.findById(id);
|
||||||
ValidationUtil.isNull(sOutSourceInspectionCertificate,"SOutSourceInspectionCertificate","id",id);
|
OutSourceInspectionCertificate outSourceInspectionCertificate = invoiceOptional.get();
|
||||||
return outSourceInspectionCertificateMapper.toDto(sOutSourceInspectionCertificate.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
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public OutSourceInspectionCertificateDTO create(OutSourceInspectionCertificate resources) {
|
public OutSourceInspectionCertificateDTO create(CreateOutSourceInspectionCertificateRequest createOutSourceInspectionCertificateRequest) {
|
||||||
return outSourceInspectionCertificateMapper.toDto(outSourceInspectionCertificateRepository.save(resources));
|
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
|
@Override
|
||||||
|
|
|
@ -49,6 +49,7 @@ import javax.persistence.criteria.Predicate;
|
||||||
import javax.persistence.criteria.Root;
|
import javax.persistence.criteria.Root;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 委外加工单服务累
|
||||||
* @author jie
|
* @author jie
|
||||||
* @date 2019-08-17
|
* @date 2019-08-17
|
||||||
*/
|
*/
|
||||||
|
@ -70,9 +71,9 @@ public class OutSourceProcessSheetServiceImpl implements OutSourceProcessSheetSe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object queryAll(OutSourceProcessSheetQueryCriteria criteria, Pageable pageable){
|
public Object queryAll(OutSourceProcessSheetQueryCriteria criteria, Pageable pageable){
|
||||||
Specification<OutSourceProcessSheetProduct> specification = new Specification<OutSourceProcessSheetProduct>() {
|
Specification<OutSourceProcessSheet> specification = new Specification<OutSourceProcessSheet>() {
|
||||||
@Override
|
@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<>();
|
List<Predicate> targetPredicateList = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -92,9 +93,9 @@ public class OutSourceProcessSheetServiceImpl implements OutSourceProcessSheetSe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object queryAll(OutSourceProcessSheetQueryCriteria criteria){
|
public Object queryAll(OutSourceProcessSheetQueryCriteria criteria){
|
||||||
Specification<OutSourceProcessSheetProduct> specification = new Specification<OutSourceProcessSheetProduct>() {
|
Specification<OutSourceProcessSheet> specification = new Specification<OutSourceProcessSheet>() {
|
||||||
@Override
|
@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<>();
|
List<Predicate> targetPredicateList = new ArrayList<>();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue