diff --git a/ruoyi-admin/src/main/java/com/ruoyi/erp/service/impl/ErpInboundOrderServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/erp/service/impl/ErpInboundOrderServiceImpl.java index f9830a12..361e5ede 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/erp/service/impl/ErpInboundOrderServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/erp/service/impl/ErpInboundOrderServiceImpl.java @@ -1,7 +1,9 @@ package com.ruoyi.erp.service.impl; +import java.math.BigDecimal; import java.util.Date; import java.util.List; +import java.util.Set; import java.util.stream.Collectors; import cn.hutool.core.collection.CollectionUtil; @@ -31,6 +33,7 @@ import com.ruoyi.system.domain.SysSalesOrderChild; import com.ruoyi.system.mapper.SysMakeorderBomMapper; import com.ruoyi.system.mapper.SysSalesOrderChildMapper; import com.ruoyi.warehouse.domain.WarehouseOutOrderDetail; +import com.ruoyi.warehouse.domain.WarehouseStorageOrderDetail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.erp.mapper.ErpInboundOrderMapper; @@ -132,15 +135,49 @@ public class ErpInboundOrderServiceImpl implements IErpInboundOrderService qualityOrder.setCreateTime(new Date()); qualityOrder.setCreateBy(loginName); + + + // 获取所有makeorderBomId对应的SysMakeorderBom对象 List sysMakeorderBoms = erpInboundOrder.getInboundDetails().stream() .map(ErpInboundOrderDetail::getMakeorderBomId) .map(this::getSysMakeorderBomById) .collect(Collectors.toList()); + // 筛选加工方式只有委内加工的数据 + List filterSysMakeorderBoms = sysMakeorderBoms.stream() + .filter(sysMakeorderBom -> "1".equals(sysMakeorderBom.getProcessMethod())) + .collect(Collectors.toList()); + + // 创建一个Set来存储filterSysMakeorderBoms中的所有物料号MaterialNo + Set materialNoSet = filterSysMakeorderBoms.stream() + .map(SysMakeorderBom::getMaterialNo) + .collect(Collectors.toSet()); + + // 使用materialNoSet来过滤erpInboundOrder.getInboundDetails() + List filteredErpInboundOrderDetails = erpInboundOrder.getInboundDetails().stream() + .filter(detail -> materialNoSet.contains(detail.getMaterialNo()) && detail.getCurrentNum() != null) + .collect(Collectors.toList()); + + + + BigDecimal makeInTotalPrice = BigDecimal.ZERO; + //计算委内数据的加工费总价 + boolean hasMakeInTotalPriceNull = filteredErpInboundOrderDetails.stream() + .anyMatch(item -> item.getProcessFeeUnitPrice() == null); + + if (hasMakeInTotalPriceNull) { + throw new BusinessException("存在委内加工费为空,请检查!"); + } + // 计算各个字段的总和 + makeInTotalPrice = filteredErpInboundOrderDetails.stream() + .map(ErpInboundOrderDetail::getProcessFeeUnitPrice) + .reduce(BigDecimal.ZERO,BigDecimal::add); + //加入到品质单中 + qualityOrder.setMakeInTotalPrice(makeInTotalPrice); //添加委内加工品质单详情数据 - addQualityOrderDetail(erpInboundOrder,qualityOrderCode,sysMakeorderBoms); + addQualityOrderDetail(erpInboundOrder, filteredErpInboundOrderDetails,qualityOrderCode,filterSysMakeorderBoms); //添加委内加工品质单报告数据 - addQualityOrderReport(erpInboundOrder,qualityOrderCode,sysMakeorderBoms); + addQualityOrderReport(filteredErpInboundOrderDetails,qualityOrderCode,filterSysMakeorderBoms); //插入品质单 return qualityOrderMapper.insertQualityOrder(qualityOrder); @@ -152,13 +189,13 @@ public class ErpInboundOrderServiceImpl implements IErpInboundOrderService } //添加委内加工品质单报告数据 - private void addQualityOrderReport(ErpInboundOrder erpInboundOrder,String qualityOrderCode,List sysMakeorderBoms) { - List inboundDetails = erpInboundOrder.getInboundDetails(); - if (CollectionUtils.isEmpty(inboundDetails)) { - throw new BusinessException("委内加工详情数据为空"); - } - for (int i = 0; i < inboundDetails.size(); i++) { - ErpInboundOrderDetail inboundDetail = inboundDetails.get(i); + private void addQualityOrderReport(List filteredErpInboundOrderDetails,String qualityOrderCode,List sysMakeorderBoms) { +// List inboundDetails = erpInboundOrder.getInboundDetails(); +// if (CollectionUtils.isEmpty(inboundDetails)) { +// throw new BusinessException("委内加工详情数据为空"); +// } + for (int i = 0; i < filteredErpInboundOrderDetails.size(); i++) { + ErpInboundOrderDetail inboundDetail = filteredErpInboundOrderDetails.get(i); SysMakeorderBom sysMakeorderBom = sysMakeorderBoms.get(i); QualityOrderReport qualityOrderReport = new QualityOrderReport(); qualityOrderReport.setQualityOrderCode(qualityOrderCode); @@ -187,13 +224,13 @@ public class ErpInboundOrderServiceImpl implements IErpInboundOrderService } //添加委内加工品质单详情数据 - private void addQualityOrderDetail(ErpInboundOrder erpInboundOrder,String qualityOrderCode,List sysMakeorderBoms) { - List inboundDetails = erpInboundOrder.getInboundDetails(); - if (CollectionUtils.isEmpty(inboundDetails)) { - throw new BusinessException("委内加工详情数据为空"); - } - for (int i = 0; i < inboundDetails.size(); i++) { - ErpInboundOrderDetail inboundDetail = inboundDetails.get(i); + private void addQualityOrderDetail(ErpInboundOrder erpInboundOrder,List filteredErpInboundOrderDetails,String qualityOrderCode,List sysMakeorderBoms) { +// List inboundDetails = erpInboundOrder.getInboundDetails(); +// if (CollectionUtils.isEmpty(inboundDetails)) { +// throw new BusinessException("委内加工详情数据为空"); +// } + for (int i = 0; i < filteredErpInboundOrderDetails.size(); i++) { + ErpInboundOrderDetail inboundDetail = filteredErpInboundOrderDetails.get(i); SysMakeorderBom sysMakeorderBom = sysMakeorderBoms.get(i); QualityOrderDetail qualityOrderDetail = new QualityOrderDetail(); @@ -221,6 +258,8 @@ public class ErpInboundOrderServiceImpl implements IErpInboundOrderService qualityOrderDetail.setMaterialType(sysMakeorderBom.getMaterialType()); //添加委内已完成数 qualityOrderDetail.setMakeInNum(Math.toIntExact(inboundDetail.getCurrentNum())); + //添加委内加工费单价 + qualityOrderDetail.setMakeInUnitPrice(inboundDetail.getProcessFeeUnitPrice()); qualityOrderDetail.setCreateBy(ShiroUtils.getLoginName()); qualityOrderDetail.setCreateTime(new Date()); qualityOrderDetailMapper.insertQualityOrderDetail(qualityOrderDetail); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrder.java b/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrder.java index 14d68db3..1f2e4166 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrder.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrder.java @@ -1,5 +1,6 @@ package com.ruoyi.quality.domain; +import java.math.BigDecimal; import java.util.Date; import java.util.List; @@ -58,6 +59,9 @@ public class QualityOrder extends BaseEntity @Excel(name = "品质不合格数") private Integer qualityUnqualifiedNum; + /** 委内加工费总价 */ + private BigDecimal makeInTotalPrice; + /** 仓库Id */ @Excel(name = "仓库Id") private String warehouseCode; @@ -168,7 +172,16 @@ public class QualityOrder extends BaseEntity { return qualityUnqualifiedNum; } - public void setDeliveryInspectionTime(Date deliveryInspectionTime) + + public BigDecimal getMakeInTotalPrice() { + return makeInTotalPrice; + } + + public void setMakeInTotalPrice(BigDecimal makeInTotalPrice) { + this.makeInTotalPrice = makeInTotalPrice; + } + + public void setDeliveryInspectionTime(Date deliveryInspectionTime) { this.deliveryInspectionTime = deliveryInspectionTime; } @@ -224,6 +237,7 @@ public class QualityOrder extends BaseEntity .append("thisArrivedNum", getThisArrivedNum()) .append("qualityQualifiedNum", getQualityQualifiedNum()) .append("qualityUnqualifiedNum", getQualityUnqualifiedNum()) + .append("makeInTotalPrice",getMakeInTotalPrice()) .append("deliveryInspectionTime", getDeliveryInspectionTime()) .append("qualityEmployee", getQualityEmployee()) .append("warehouseCode", getWarehouseCode()) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrderDetail.java b/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrderDetail.java index 53504c23..1f0ab2c8 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrderDetail.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrderDetail.java @@ -1,5 +1,6 @@ package com.ruoyi.quality.domain; +import java.math.BigDecimal; import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -142,6 +143,10 @@ public class QualityOrderDetail extends BaseEntity private Integer makeInNum; + /** 委内加工费单价 */ + private BigDecimal makeInUnitPrice; + + public void setQualityOrderDetailId(Long qualityOrderDetailId) { this.qualityOrderDetailId = qualityOrderDetailId; @@ -405,6 +410,14 @@ public class QualityOrderDetail extends BaseEntity this.makeInNum = makeInNum; } + public BigDecimal getMakeInUnitPrice() { + return makeInUnitPrice; + } + + public void setMakeInUnitPrice(BigDecimal makeInUnitPrice) { + this.makeInUnitPrice = makeInUnitPrice; + } + public String getMaterialDeptType() { return materialDeptType; } @@ -447,6 +460,7 @@ public class QualityOrderDetail extends BaseEntity .append("qualityQualifiedNum", getQualityQualifiedNum()) .append("qualityUnqualifiedNum", getQualityUnqualifiedNum()) .append("makeInNum",getMakeInNum()) + .append("makeInUnitPrice",getMakeInUnitPrice()) .append("remark", getRemark()) .append("createBy", getCreateBy()) .append("createTime", getCreateTime()) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseStorageOrder.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseStorageOrder.java index e1b3bb94..1c10a17f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseStorageOrder.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseStorageOrder.java @@ -1,5 +1,6 @@ package com.ruoyi.warehouse.domain; +import java.math.BigDecimal; import java.util.Date; import java.util.List; @@ -80,6 +81,10 @@ public class WarehouseStorageOrder extends BaseEntity @Excel(name = "入库数量") private Integer storageNum; + + /** 委内加工费总价 */ + private BigDecimal makeInTotalPrice; + /** 到货时间 */ @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "到货时间", width = 30, dateFormat = "yyyy-MM-dd") @@ -259,7 +264,16 @@ public class WarehouseStorageOrder extends BaseEntity { return storageNum; } - public void setArrivedTime(Date arrivedTime) + + public BigDecimal getMakeInTotalPrice() { + return makeInTotalPrice; + } + + public void setMakeInTotalPrice(BigDecimal makeInTotalPrice) { + this.makeInTotalPrice = makeInTotalPrice; + } + + public void setArrivedTime(Date arrivedTime) { this.arrivedTime = arrivedTime; } @@ -366,6 +380,7 @@ public class WarehouseStorageOrder extends BaseEntity .append("qualityQualifiedNum", getQualityQualifiedNum()) .append("qualityUnqualifiedNum", getQualityUnqualifiedNum()) .append("storageNum", getStorageNum()) + .append("makeInTotalPrice",getMakeInTotalPrice()) .append("arrivedTime", getArrivedTime()) .append("temporaryTime", getTemporaryTime()) .append("deliveryInspectionTime", getDeliveryInspectionTime()) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseStorageOrderDetail.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseStorageOrderDetail.java index f491d7cf..0d536378 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseStorageOrderDetail.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseStorageOrderDetail.java @@ -1,5 +1,6 @@ package com.ruoyi.warehouse.domain; +import java.math.BigDecimal; import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -172,6 +173,10 @@ public class WarehouseStorageOrderDetail extends BaseEntity @Excel(name = "退换货数") private Integer refundsExchangesNum; + + /** 委内加工费单价 */ + private BigDecimal makeInUnitPrice; + /** 到货时间 */ @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "到货时间", width = 30, dateFormat = "yyyy-MM-dd") @@ -706,6 +711,14 @@ public class WarehouseStorageOrderDetail extends BaseEntity this.customerCompanyAddress = customerCompanyAddress; } + public BigDecimal getMakeInUnitPrice() { + return makeInUnitPrice; + } + + public void setMakeInUnitPrice(BigDecimal makeInUnitPrice) { + this.makeInUnitPrice = makeInUnitPrice; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -766,6 +779,7 @@ public class WarehouseStorageOrderDetail extends BaseEntity .append("createBy", getCreateBy()) .append("updateBy", getUpdateBy()) .append("updateTime", getUpdateTime()) + .append("makeInUnitPrice",getMakeInUnitPrice()) .toString(); } } diff --git a/ruoyi-admin/src/main/resources/mapper/quality/QualityOrderDetailMapper.xml b/ruoyi-admin/src/main/resources/mapper/quality/QualityOrderDetailMapper.xml index 578828a6..e1aaf38f 100644 --- a/ruoyi-admin/src/main/resources/mapper/quality/QualityOrderDetailMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/quality/QualityOrderDetailMapper.xml @@ -36,6 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -44,7 +45,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select quality_order_detail_id, quality_order_code, in_storage_code, related_order_code, quality_status, quality_order_type, quality_storage_status, delivery_inspection_time, warehouse_code, warehouse_name, supplier_code, supplier_name, customer_contact, contact_number, supplier_address, material_no, material_name, material_type, material_photoUrl, material_brand, material_unit, material_describe, material_process_method, material_dept_type ,make_total, actual_arrive_num, this_arrived_num, quality_hasqualified_num, quality_qualified_num, quality_unqualified_num, make_in_num, remark, create_by, create_time, update_by, update_time from quality_order_detail + select quality_order_detail_id, + quality_order_code, + in_storage_code, + related_order_code, + quality_status, + quality_order_type, + quality_storage_status, + delivery_inspection_time, + warehouse_code, + warehouse_name, + supplier_code, + supplier_name, + customer_contact, + contact_number, + supplier_address, + material_no, + material_name, + material_type, + material_photoUrl, + material_brand, + material_unit, + material_describe, + material_process_method, + material_dept_type, + make_total, + actual_arrive_num, + this_arrived_num, + quality_hasqualified_num, + quality_qualified_num, + quality_unqualified_num, + make_in_num, + make_in_unit_price, + remark, + create_by, + create_time, + update_by, + update_time + from quality_order_detail @@ -67,6 +88,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" this_arrived_num, quality_qualified_num, quality_unqualified_num, + make_in_total_price, delivery_inspection_time, quality_employee, warehouse_code, @@ -87,6 +109,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{thisArrivedNum}, #{qualityQualifiedNum}, #{qualityUnqualifiedNum}, + #{makeInTotalPrice}, #{deliveryInspectionTime}, #{qualityEmployee}, #{warehouseCode}, @@ -111,6 +134,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" this_arrived_num = #{thisArrivedNum}, quality_qualified_num = #{qualityQualifiedNum}, quality_unqualified_num = #{qualityUnqualifiedNum}, + make_in_total_price = #{makeInTotalPrice}, delivery_inspection_time = #{deliveryInspectionTime}, quality_employee = #{qualityEmployee}, warehouse_code = #{warehouseCode}, diff --git a/ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseStorageOrderDetailMapper.xml b/ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseStorageOrderDetailMapper.xml index db8e8231..4413946e 100644 --- a/ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseStorageOrderDetailMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseStorageOrderDetailMapper.xml @@ -41,6 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -65,7 +66,65 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select warehouse_storage_detail_id, warehouse_storage_code, related_order_code, warehouse_storage_status, warehouse_quality_status, warehouse_storage_type, warehouse_storage_class, warehouse_order_type, warehouse_dept_type, warehouse_employee, warehouse_code, warehouse_name, warehouse_detail_address, supplier_code, supplier_name, customer_contact, contact_number, supplier_address, customer_id, customer_name, customer_contact_people, customer_contact_number, customer_company_address, material_no, material_name, material_type, material_photoUrl, material_brand, material_unit, material_describe, material_process_method, material_dept_type, make_total, notify_has_arrived_num, notify_arrive_num, actual_has_arrived_num, actual_arrive_num, temporary_has_qualified_num, temporary_qualified_num, has_storage_num, storage_num, make_storage_num ,quality_has_qualified_num, quality_qualified_num, refunds_exchanges_num, arrived_time, temporary_time, delivery_inspection_time, quality_time, storage_time, temporary_remark, temporary_report_url, storage_location, create_time, create_by, update_by, update_time from warehouse_storage_order_detail + select warehouse_storage_detail_id, + warehouse_storage_code, + related_order_code, + warehouse_storage_status, + warehouse_quality_status, + warehouse_storage_type, + warehouse_storage_class, + warehouse_order_type, + warehouse_dept_type, + warehouse_employee, + warehouse_code, + warehouse_name, + warehouse_detail_address, + supplier_code, + supplier_name, + customer_contact, + contact_number, + supplier_address, + customer_id, + customer_name, + customer_contact_people, + customer_contact_number, + customer_company_address, + material_no, + material_name, + material_type, + material_photoUrl, + material_brand, + material_unit, + material_describe, + material_process_method, + material_dept_type, + make_total, + notify_has_arrived_num, + notify_arrive_num, + actual_has_arrived_num, + actual_arrive_num, + temporary_has_qualified_num, + temporary_qualified_num, + has_storage_num, + storage_num, + make_in_unit_price, + make_storage_num, + quality_has_qualified_num, + quality_qualified_num, + refunds_exchanges_num, + arrived_time, + temporary_time, + delivery_inspection_time, + quality_time, + storage_time, + temporary_remark, + temporary_report_url, + storage_location, + create_time, + create_by, + update_by, + update_time + from warehouse_storage_order_detail