mirror of https://github.com/elunez/eladmin
委外验收单 状态
parent
1dce7f2885
commit
0970a97d7c
|
@ -83,7 +83,7 @@ public class ProductInfoServiceImpl implements ProductInfoService {
|
|||
|
||||
String productCode = criteria.getProductCode();
|
||||
if(!StringUtils.isEmpty(productCode)){
|
||||
Predicate productCodePredicate = criteriaBuilder.equal(root.get("productCode"), productCode);
|
||||
Predicate productCodePredicate = criteriaBuilder.like(root.get("productCode").as(String.class), "%" + criteria.getProductCode() + "%");
|
||||
targetPredicateList.add(productCodePredicate);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ public class CustomerOrderProduct implements Serializable {
|
|||
|
||||
// 所属客户订单
|
||||
@Column(name = "customer_order_code")
|
||||
private Long customerOrderCode;
|
||||
private String customerOrderCode;
|
||||
|
||||
// 产品主键
|
||||
@Column(name = "product_id")
|
||||
|
|
|
@ -37,8 +37,8 @@ public interface CustomerOrderRepository extends JpaRepository<CustomerOrder, Lo
|
|||
* @param procStatus
|
||||
*/
|
||||
@Modifying
|
||||
@Query(value = "update s_customer_order set proc_status = 0 where id = ?1", nativeQuery = true)
|
||||
void updateProcStatus(String procStatus);
|
||||
@Query(value = "update s_customer_order set proc_status = ?1 where customer_order_code = ?2", nativeQuery = true)
|
||||
void updateProcStatus(String procStatus, String customerOrderCode);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -236,6 +236,7 @@ public class CustomerOrderServiceImpl implements CustomerOrderService {
|
|||
BeanUtils.copyProperties(customerOrderProductRequest, customerOrderProduct);
|
||||
customerOrderProduct.setCustomerOrderId(customerOrder.getId());
|
||||
customerOrderProduct.setStatus(true);
|
||||
customerOrderProduct.setCustomerOrderCode(customerOrderCode);
|
||||
ProductInfo productInfo = productInfoRepository.findByProductCode(customerOrderProductRequest.getProductCode());
|
||||
customerOrderProduct.setProductId(productInfo.getId());
|
||||
Long productNumber = customerOrderProduct.getProductNumber();
|
||||
|
|
|
@ -215,6 +215,10 @@ public class InvoiceServiceImpl implements InvoiceService {
|
|||
throw new BadRequestException("客户订单编号不能为空!");
|
||||
}
|
||||
|
||||
CustomerOrder customerOrder = customerOrderRepository.findByCustomerOrderCodeAndStatusTrue(customerOrderCode);
|
||||
customerOrder.setProcStatus(ProcStatusEnum.SENDING_GOOD.getCode());
|
||||
customerOrderRepository.save(customerOrder);
|
||||
|
||||
// 客户ID
|
||||
Long customerId = createInvoiceRequest.getCustomerId();
|
||||
if(null == customerId){
|
||||
|
@ -230,6 +234,7 @@ public class InvoiceServiceImpl implements InvoiceService {
|
|||
throw new BadRequestException("客户不存在!");
|
||||
}
|
||||
|
||||
|
||||
invoice.setCustomerName(customerInfo.getCustomerName());
|
||||
|
||||
// 销售发货单号
|
||||
|
@ -378,10 +383,10 @@ public class InvoiceServiceImpl implements InvoiceService {
|
|||
String productCodeTemp = entry.getKey();
|
||||
long productNumberTemp = entry.getValue();
|
||||
long productNumberTempExist = existProduct.get(productCodeTemp);
|
||||
if(productNumberTemp == productNumberTempExist || productNumberTemp > productNumberTempExist){
|
||||
customerOrderRepository.updateProcStatus(ProcStatusEnum.COMPLETED.getCode());
|
||||
if(productNumberTemp == productNumberTempExist){
|
||||
customerOrderRepository.updateProcStatus(ProcStatusEnum.COMPLETED.getCode(), customerOrderCode);
|
||||
}else{
|
||||
customerOrderRepository.updateProcStatus(ProcStatusEnum.SENDING_GOOD.getCode());
|
||||
customerOrderRepository.updateProcStatus(ProcStatusEnum.SENDING_GOOD.getCode(), customerOrderCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,10 @@ public class OutSourceInspectionCertificateProduct implements Serializable {
|
|||
@Column(name = "out_source_inspection_certificate_id")
|
||||
private Long outSourceInspectionCertificateId;
|
||||
|
||||
// 所属委外验收单
|
||||
@Column(name = "out_source_inspection_certificate_code")
|
||||
private String outSourceInspectionCertificateCode;
|
||||
|
||||
@Column(name = "product_code")
|
||||
private String productCode;
|
||||
|
||||
|
@ -63,6 +67,13 @@ public class OutSourceInspectionCertificateProduct implements Serializable {
|
|||
@Column(name = "scrap_number")
|
||||
private Integer scrapNumber;
|
||||
|
||||
|
||||
// 所属委外加工单
|
||||
@Column(name = "out_source_process_sheet_code")
|
||||
private String outSourceProcessSheetCode;
|
||||
|
||||
|
||||
|
||||
public void copy(OutSourceInspectionCertificateProduct source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
|
|
|
@ -42,6 +42,11 @@ public class OutSourceProcessSheetProduct implements Serializable {
|
|||
@Column(name = "out_source_process_sheet_id")
|
||||
private Long outSourceProcessSheetId;
|
||||
|
||||
|
||||
@Column(name = "out_source_process_sheet_code")
|
||||
private String outSourceProcessSheetCode;
|
||||
|
||||
|
||||
// 产品主键
|
||||
@Column(name = "product_id",nullable = false)
|
||||
private Long productId;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package me.zhengjie.modules.wms.outSourceProductSheet.repository;
|
||||
|
||||
import me.zhengjie.modules.wms.invoice.domain.InvoiceProduct;
|
||||
import me.zhengjie.modules.wms.outSourceProductSheet.domain.OutSourceInspectionCertificateProduct;
|
||||
import me.zhengjie.modules.wms.outSourceProductSheet.domain.OutSourceProcessSheetProduct;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
@ -26,4 +27,12 @@ public interface OutSourceInspectionCertificateProductRepository extends JpaRepo
|
|||
@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);
|
||||
|
||||
|
||||
/**
|
||||
* 根据委外加工单,查看委外验收单产品列表
|
||||
* @param outSourceProcessSheetCode
|
||||
* @return
|
||||
*/
|
||||
List<OutSourceInspectionCertificateProduct> findByOutSourceProcessSheetCodeAndStatusTrue(String outSourceProcessSheetCode);
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package me.zhengjie.modules.wms.outSourceProductSheet.repository;
|
||||
|
||||
import me.zhengjie.modules.wms.invoice.domain.InvoiceProduct;
|
||||
import me.zhengjie.modules.wms.outSourceProductSheet.domain.OutSourceProcessSheetProduct;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
@ -23,6 +22,13 @@ public interface OutSourceProcessSheetProductRepository extends JpaRepository<Ou
|
|||
@Query(value ="select * from s_out_source_process_sheet_product where out_source_process_sheet_id = ?1 and status =1", nativeQuery = true)
|
||||
List<OutSourceProcessSheetProduct> queryByOutSourceProcessSheetIdAndStatusTrue(Long outSourceProcessSheetId);
|
||||
|
||||
/**
|
||||
* 根据委外加工单code查看委外加工单产品信息,且status为true
|
||||
* @param outSourceProcessSheetCode
|
||||
* @return
|
||||
*/
|
||||
List<OutSourceProcessSheetProduct> queryByOutSourceProcessSheetCodeAndStatusTrue(String outSourceProcessSheetCode);
|
||||
|
||||
@Modifying
|
||||
@Query(value = "delete from s_out_source_process_sheet_product where product_code = ?1 and out_source_process_sheet_id = ?2", nativeQuery = true)
|
||||
void deleteByProductCodeAndOutSourceProcessSheetId(String productCode, Long outSourceProcessSheetId);
|
||||
|
|
|
@ -3,6 +3,7 @@ package me.zhengjie.modules.wms.outSourceProductSheet.repository;
|
|||
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.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
/**
|
||||
|
@ -18,4 +19,8 @@ public interface OutSourceProcessSheetRepository extends JpaRepository<OutSource
|
|||
*/
|
||||
@Query(value ="select * from s_out_source_process_sheet where out_source_process_sheet_code = ?1 and status = 1", nativeQuery = true)
|
||||
OutSourceProcessSheet findByOutSourceProcessSheetCode(String outSourceProcessSheetCode);
|
||||
|
||||
@Modifying
|
||||
@Query(value = "update s_out_source_process_sheet set proc_status = ?1 where out_source_process_sheet_code = ?2", nativeQuery = true)
|
||||
void updateProcStatus(String procStatus, String outSourceProcessSheetCode);
|
||||
}
|
|
@ -17,7 +17,7 @@ import java.util.List;
|
|||
public class CreateOutSourceInspectionCertificateRequest implements Serializable {
|
||||
|
||||
|
||||
// 所属委外加工单
|
||||
// 所属委外加工单code
|
||||
private String outSourceProcessSheetCode;
|
||||
|
||||
// 制单人
|
||||
|
|
|
@ -27,6 +27,8 @@ public class OutSourceInspectionCertificateProductDTO implements Serializable {
|
|||
// 所属委外验收单
|
||||
private Long outSourceInspectionCertificateId;
|
||||
|
||||
private Long outSourceInspectionCertificateCode;
|
||||
|
||||
private String productCode;
|
||||
|
||||
private Long productId;
|
||||
|
@ -44,4 +46,7 @@ public class OutSourceInspectionCertificateProductDTO implements Serializable {
|
|||
// 报废数量
|
||||
private Integer scrapNumber;
|
||||
|
||||
// 所属委外加工单
|
||||
private String outSourceProcessSheetCode;
|
||||
|
||||
}
|
|
@ -27,6 +27,8 @@ public class OutSourceProcessSheetProductDTO implements Serializable {
|
|||
// 所属委外加工单
|
||||
private Long outSourceProcessSheetId;
|
||||
|
||||
private String outSourceProcessSheetCode;
|
||||
|
||||
// 产品主键
|
||||
private Long productId;
|
||||
|
||||
|
|
|
@ -12,16 +12,19 @@ import me.zhengjie.modules.system.repository.UserRepository;
|
|||
import me.zhengjie.modules.system.service.UserService;
|
||||
import me.zhengjie.modules.system.service.dto.UserDTO;
|
||||
import me.zhengjie.modules.system.service.dto.UserQueryCriteria;
|
||||
import me.zhengjie.modules.wms.customerOrder.domain.CustomerOrderProduct;
|
||||
import me.zhengjie.modules.wms.invoice.domain.InvoiceProduct;
|
||||
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.repository.OutSourceProcessSheetProductRepository;
|
||||
import me.zhengjie.modules.wms.outSourceProductSheet.repository.OutSourceProcessSheetRepository;
|
||||
import me.zhengjie.modules.wms.outSourceProductSheet.request.*;
|
||||
import me.zhengjie.modules.wms.outSourceProductSheet.service.dto.*;
|
||||
import me.zhengjie.modules.wms.outSourceProductSheet.service.mapper.OutSourceInspectionCertificateProductMapper;
|
||||
import me.zhengjie.utils.SecurityUtils;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
import me.zhengjie.utils.*;
|
||||
import me.zhengjie.modules.wms.outSourceProductSheet.repository.OutSourceInspectionCertificateRepository;
|
||||
import me.zhengjie.modules.wms.outSourceProductSheet.service.OutSourceInspectionCertificateService;
|
||||
import me.zhengjie.modules.wms.outSourceProductSheet.service.mapper.OutSourceInspectionCertificateMapper;
|
||||
|
@ -32,17 +35,12 @@ 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.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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;
|
||||
|
||||
|
@ -79,6 +77,12 @@ public class OutSourceInspectionCertificateServiceImpl implements OutSourceInspe
|
|||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Autowired
|
||||
private OutSourceProcessSheetProductRepository outSourceProcessSheetProductRepository;
|
||||
|
||||
@Autowired
|
||||
private OutSourceProcessSheetRepository outSourceProcessSheetRepository;
|
||||
|
||||
@Override
|
||||
public Object queryAll(OutSourceInspectionCertificateQueryCriteria criteria, Pageable pageable){
|
||||
Specification<OutSourceInspectionCertificate> specification = new Specification<OutSourceInspectionCertificate>() {
|
||||
|
@ -148,9 +152,12 @@ public class OutSourceInspectionCertificateServiceImpl implements OutSourceInspe
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public OutSourceInspectionCertificateDTO create(CreateOutSourceInspectionCertificateRequest createOutSourceInspectionCertificateRequest) {
|
||||
// 委外加工单code
|
||||
String outSourceProcessSheetCode = createOutSourceInspectionCertificateRequest.getOutSourceProcessSheetCode();
|
||||
OutSourceInspectionCertificate outSourceInspectionCertificate = new OutSourceInspectionCertificate();
|
||||
BeanUtils.copyProperties(createOutSourceInspectionCertificateRequest, outSourceInspectionCertificate);
|
||||
|
||||
// 委外验收单code
|
||||
String outSourceInspectionCertificateCode = outSourceInspectionCertificate.getOutSourceInspectionCertificateCode();
|
||||
if(!StringUtils.hasLength(outSourceInspectionCertificateCode)){
|
||||
throw new BadRequestException("委外验收单单据编号不能为空!");
|
||||
|
@ -172,6 +179,8 @@ public class OutSourceInspectionCertificateServiceImpl implements OutSourceInspe
|
|||
OutSourceInspectionCertificateProduct outSourceInspectionCertificateProduct = new OutSourceInspectionCertificateProduct();
|
||||
BeanUtils.copyProperties(outSourceInspectionCertificateProductRequest, outSourceInspectionCertificateProduct);
|
||||
outSourceInspectionCertificateProduct.setStatus(true);
|
||||
outSourceInspectionCertificateProduct.setOutSourceProcessSheetCode(outSourceProcessSheetCode);
|
||||
outSourceInspectionCertificateProduct.setOutSourceInspectionCertificateCode(outSourceInspectionCertificateCode);
|
||||
outSourceInspectionCertificateProduct.setOutSourceInspectionCertificateId(outSourceInspectionCertificate.getId());
|
||||
outSourceInspectionCertificateProductRepository.save(outSourceInspectionCertificateProduct);
|
||||
}
|
||||
|
@ -217,7 +226,46 @@ public class OutSourceInspectionCertificateServiceImpl implements OutSourceInspe
|
|||
messageRepository.saveAll(messageList);
|
||||
}
|
||||
|
||||
// 修改为外加工单状态
|
||||
// 查看指定委外加工单下的委外验收单产品信息
|
||||
Map<String, Long> existProduct = new HashMap<>();
|
||||
List<OutSourceInspectionCertificateProduct> existProductList = outSourceInspectionCertificateProductRepository.findByOutSourceProcessSheetCodeAndStatusTrue(outSourceProcessSheetCode);
|
||||
if(!CollectionUtils.isEmpty(existProductList)){
|
||||
Map<String, List<OutSourceInspectionCertificateProduct>> existProductMap = existProductList.stream().collect(Collectors.groupingBy(OutSourceInspectionCertificateProduct::getProductCode));
|
||||
for(Map.Entry<String, List<OutSourceInspectionCertificateProduct>> entry : existProductMap.entrySet()){
|
||||
String productCode = entry.getKey();
|
||||
List<OutSourceInspectionCertificateProduct> invoiceProductListTemp = entry.getValue();
|
||||
if(!CollectionUtils.isEmpty(invoiceProductListTemp)){
|
||||
Long productNumberTotal = invoiceProductListTemp.stream().mapToLong(OutSourceInspectionCertificateProduct::getQualifiedNumber).sum();
|
||||
existProduct.put(productCode, productNumberTotal);
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, Long> sourceProduct = new HashMap<>();
|
||||
List<OutSourceProcessSheetProduct> sourceProductList = outSourceProcessSheetProductRepository.queryByOutSourceProcessSheetCodeAndStatusTrue(outSourceProcessSheetCode);
|
||||
if(!CollectionUtils.isEmpty(sourceProductList)){
|
||||
Map<String, List<OutSourceProcessSheetProduct>> sourceProductMap = sourceProductList.stream().collect(Collectors.groupingBy(OutSourceProcessSheetProduct::getProductCode));
|
||||
for(Map.Entry<String, List<OutSourceProcessSheetProduct>> entry : sourceProductMap.entrySet()){
|
||||
String productCode = entry.getKey();
|
||||
List<OutSourceProcessSheetProduct> customerOrderProductListTemp = entry.getValue();
|
||||
if(!CollectionUtils.isEmpty(customerOrderProductListTemp)){
|
||||
Long productNumberTotal = customerOrderProductListTemp.stream().mapToLong(OutSourceProcessSheetProduct::getProductNumber).sum();
|
||||
sourceProduct.put(productCode, productNumberTotal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!CollectionUtils.isEmpty(sourceProduct)){
|
||||
for(Map.Entry<String, Long> entry : sourceProduct.entrySet()){
|
||||
String productCodeTemp = entry.getKey();
|
||||
long productNumberTemp = entry.getValue();
|
||||
long productNumberTempExist = existProduct.get(productCodeTemp);
|
||||
if(productNumberTemp == productNumberTempExist){
|
||||
outSourceProcessSheetRepository.updateProcStatus(ProcStatusEnum.COMPLETED.getCode(), outSourceProcessSheetCode);
|
||||
}else{
|
||||
outSourceProcessSheetRepository.updateProcStatus(ProcStatusEnum.OUT_SOURCE_INSPECTION_ING.getCode(), outSourceProcessSheetCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("单据编号:插入消息失败!");
|
||||
}
|
||||
|
|
|
@ -223,6 +223,7 @@ public class OutSourceProcessSheetServiceImpl implements OutSourceProcessSheetSe
|
|||
OutSourceProcessSheetProduct outSourceProcessSheetProduct = new OutSourceProcessSheetProduct();
|
||||
BeanUtils.copyProperties(outSourceProcessSheetProductRequest, outSourceProcessSheetProduct);
|
||||
outSourceProcessSheetProduct.setStatus(true);
|
||||
outSourceProcessSheetProduct.setOutSourceProcessSheetCode(outSourceProcessSheetCode);
|
||||
outSourceProcessSheetProduct.setOutSourceProcessSheetId(outSourceProcessSheet.getId());
|
||||
outSourceProcessSheetProductRepository.save(outSourceProcessSheetProduct);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue