mirror of https://github.com/elunez/eladmin
产品采购单分页查询以及列表查询
parent
72175a7d9a
commit
65dbc6ee79
|
|
@ -1,5 +1,6 @@
|
|||
package me.zhengjie.modules.wms.outSourceProductSheet.service.dto;
|
||||
|
||||
import com.sun.org.apache.xpath.internal.operations.Bool;
|
||||
import lombok.Data;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
|
@ -21,7 +22,7 @@ public class OutSourceInspectionCertificateDTO implements Serializable {
|
|||
|
||||
private Timestamp updateTime;
|
||||
|
||||
private Integer status;
|
||||
private Boolean status;
|
||||
|
||||
// 所属委外加工单
|
||||
private Long outSourceProcessSheetId;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public class OutSourceInspectionCertificateProductDTO implements Serializable {
|
|||
|
||||
private Timestamp updateTime;
|
||||
|
||||
private Integer status;
|
||||
private Boolean status;
|
||||
|
||||
// 所属委外验收单
|
||||
private Long outSourceInspectionCertificateId;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class ConsumablesPurchaseOrder implements Serializable {
|
|||
|
||||
// 状态
|
||||
@Column(name = "status")
|
||||
private Integer status;
|
||||
private Boolean status;
|
||||
|
||||
// 审核状态
|
||||
@Column(name = "audit_status")
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class ConsumablesPurchaseOrderProduct implements Serializable {
|
|||
private Timestamp updateTime;
|
||||
|
||||
@Column(name = "status")
|
||||
private Integer status;
|
||||
private Boolean status;
|
||||
|
||||
// 耗材编号
|
||||
@Column(name = "consumables_code")
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class ProductPurchaseOrder implements Serializable {
|
|||
|
||||
// 状态
|
||||
@Column(name = "status")
|
||||
private Integer status;
|
||||
private Boolean status;
|
||||
|
||||
// 审核状态
|
||||
@Column(name = "audit_status")
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class ProductPurchaseOrderProduct implements Serializable {
|
|||
private Timestamp updateTime;
|
||||
|
||||
@Column(name = "status")
|
||||
private Integer status;
|
||||
private Boolean status;
|
||||
|
||||
// 产品编号
|
||||
@Column(name = "product_code")
|
||||
|
|
|
|||
|
|
@ -14,10 +14,11 @@ import org.springframework.web.bind.annotation.*;
|
|||
import io.swagger.annotations.*;
|
||||
|
||||
/**
|
||||
* 产品采购管理控制类
|
||||
* @author jie
|
||||
* @date 2019-10-06
|
||||
*/
|
||||
@Api(tags = "ProductPurchaseOrder管理")
|
||||
@Api(tags = "产品采购管理")
|
||||
@RestController
|
||||
@RequestMapping("api")
|
||||
public class ProductPurchaseOrderController {
|
||||
|
|
@ -25,24 +26,24 @@ public class ProductPurchaseOrderController {
|
|||
@Autowired
|
||||
private ProductPurchaseOrderService productPurchaseOrderService;
|
||||
|
||||
@Log("查询ProductPurchaseOrder")
|
||||
@ApiOperation(value = "查询ProductPurchaseOrder")
|
||||
@GetMapping(value = "/productPurchaseOrder")
|
||||
@Log("分页查询产品采购单")
|
||||
@ApiOperation(value = "分页查询产品采购单")
|
||||
@GetMapping(value = "/queryProductPurchaseOrderPageList")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','PRODUCTPURCHASEORDER_ALL','PRODUCTPURCHASEORDER_SELECT')")
|
||||
public ResponseEntity getProductPurchaseOrders(ProductPurchaseOrderQueryCriteria criteria, Pageable pageable){
|
||||
public ResponseEntity queryProductPurchaseOrderPageList(ProductPurchaseOrderQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity(productPurchaseOrderService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("新增ProductPurchaseOrder")
|
||||
@ApiOperation(value = "新增ProductPurchaseOrder")
|
||||
@Log("新增产品采购单")
|
||||
@ApiOperation(value = "新增产品采购单")
|
||||
@PostMapping(value = "/productPurchaseOrder")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','PRODUCTPURCHASEORDER_ALL','PRODUCTPURCHASEORDER_CREATE')")
|
||||
public ResponseEntity create(@Validated @RequestBody ProductPurchaseOrder resources){
|
||||
return new ResponseEntity(productPurchaseOrderService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@Log("修改ProductPurchaseOrder")
|
||||
@ApiOperation(value = "修改ProductPurchaseOrder")
|
||||
@Log("修改产品采购")
|
||||
@ApiOperation(value = "修改产品采购")
|
||||
@PutMapping(value = "/productPurchaseOrder")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','PRODUCTPURCHASEORDER_ALL','PRODUCTPURCHASEORDER_EDIT')")
|
||||
public ResponseEntity update(@Validated @RequestBody ProductPurchaseOrder resources){
|
||||
|
|
@ -50,8 +51,8 @@ public class ProductPurchaseOrderController {
|
|||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除ProductPurchaseOrder")
|
||||
@ApiOperation(value = "删除ProductPurchaseOrder")
|
||||
@Log("删除产品采购")
|
||||
@ApiOperation(value = "删除产品采购")
|
||||
@DeleteMapping(value = "/productPurchaseOrder/{id}")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','PRODUCTPURCHASEORDER_ALL','PRODUCTPURCHASEORDER_DELETE')")
|
||||
public ResponseEntity delete(@PathVariable Long id){
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class ConsumablesPurchaseOrderDTO implements Serializable {
|
|||
private String purchaseUserName;
|
||||
|
||||
// 状态
|
||||
private Integer status;
|
||||
private Boolean status;
|
||||
|
||||
// 审核状态
|
||||
private Integer auditStatus;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class ConsumablesPurchaseOrderProductDTO implements Serializable {
|
|||
// 更新时间
|
||||
private Timestamp updateTime;
|
||||
|
||||
private Integer status;
|
||||
private Boolean status;
|
||||
|
||||
// 耗材编号
|
||||
private String consumablesCode;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class ProductPurchaseOrderDTO implements Serializable {
|
|||
private String purchaseUserName;
|
||||
|
||||
// 状态
|
||||
private Integer status;
|
||||
private Boolean status;
|
||||
|
||||
// 审核状态
|
||||
private Integer auditStatus;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class ProductPurchaseOrderProductDTO implements Serializable {
|
|||
// 更新时间
|
||||
private Timestamp updateTime;
|
||||
|
||||
private Integer status;
|
||||
private Boolean status;
|
||||
|
||||
// 产品编号
|
||||
private String productCode;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package me.zhengjie.modules.wms.purchase.service.impl;
|
||||
|
||||
import me.zhengjie.modules.wms.bd.domain.MeasureUnit;
|
||||
import me.zhengjie.modules.wms.purchase.domain.ProductPurchaseOrder;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
import me.zhengjie.modules.wms.purchase.repository.ProductPurchaseOrderRepository;
|
||||
|
|
@ -8,14 +9,24 @@ import me.zhengjie.modules.wms.purchase.service.dto.ProductPurchaseOrderDTO;
|
|||
import me.zhengjie.modules.wms.purchase.service.dto.ProductPurchaseOrderQueryCriteria;
|
||||
import me.zhengjie.modules.wms.purchase.service.mapper.ProductPurchaseOrderMapper;
|
||||
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 javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
|
||||
/**
|
||||
* @author jie
|
||||
|
|
@ -33,13 +44,50 @@ public class ProductPurchaseOrderServiceImpl implements ProductPurchaseOrderServ
|
|||
|
||||
@Override
|
||||
public Object queryAll(ProductPurchaseOrderQueryCriteria criteria, Pageable pageable){
|
||||
Page<ProductPurchaseOrder> page = productPurchaseOrderRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
Specification<ProductPurchaseOrder> specification = new Specification<ProductPurchaseOrder>() {
|
||||
@Override
|
||||
public Predicate toPredicate(Root<ProductPurchaseOrder> 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<ProductPurchaseOrder> page = productPurchaseOrderRepository.findAll(specification, pageable);
|
||||
return PageUtil.toPage(page.map(productPurchaseOrderMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object queryAll(ProductPurchaseOrderQueryCriteria criteria){
|
||||
return productPurchaseOrderMapper.toDto(productPurchaseOrderRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
Specification<ProductPurchaseOrder> specification = new Specification<ProductPurchaseOrder>() {
|
||||
@Override
|
||||
public Predicate toPredicate(Root<ProductPurchaseOrder> 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()]));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
List<ProductPurchaseOrder> productPurchaseOrderList = productPurchaseOrderRepository.findAll(specification);
|
||||
return productPurchaseOrderMapper.toDto(productPurchaseOrderList);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ server:
|
|||
|
||||
spring:
|
||||
profiles:
|
||||
active: dev
|
||||
active: prod
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
data:
|
||||
|
|
|
|||
Loading…
Reference in New Issue