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