huminmin
8 天以前 76c185e8b6af9a700f8812369d0001e90dee0d17
src/main/java/com/ruoyi/quality/service/impl/QualityInspectServiceImpl.java
@@ -22,6 +22,14 @@
import com.ruoyi.quality.pojo.QualityUnqualified;
import com.ruoyi.quality.service.IQualityInspectParamService;
import com.ruoyi.quality.service.IQualityInspectService;
import com.ruoyi.sales.pojo.SalesLedger;
import com.ruoyi.sales.mapper.SalesLedgerMapper;
import com.ruoyi.production.pojo.ProductOrder;
import com.ruoyi.production.pojo.ProductWorkOrder;
import com.ruoyi.production.pojo.ProductionProductMain;
import com.ruoyi.production.mapper.ProductOrderMapper;
import com.ruoyi.production.mapper.ProductWorkOrderMapper;
import com.ruoyi.production.mapper.ProductionProductMainMapper;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
@@ -50,6 +58,14 @@
    private QualityUnqualifiedMapper qualityUnqualifiedMapper;
    private QualityInspectExportHandle qualityInspectExportHandle;
    private ProductionProductMainMapper productionProductMainMapper;
    private ProductWorkOrderMapper productWorkOrderMapper;
    private ProductOrderMapper productOrderMapper;
    private SalesLedgerMapper salesLedgerMapper;
    @Override
    public int add(QualityInspectDto qualityInspectDto) {
@@ -139,7 +155,32 @@
                new HashMap<String, Object>() {{
                    put("inspect", inspect);
                    put("customerLabel", inspect.getInspectType() == 0 ? "供应商" : "客户");
                    put("customer", inspect.getInspectType() == 0 ? inspect.getSupplier() : inspect.getCustomer());
                    // 根据检验类型确定客户/供应商
            String customerValue;
            if (inspect.getInspectType() == 0) {
                // 原材料检验:直接使用供应商
                customerValue = inspect.getSupplier();
            } else {
                // 过程检验/出厂检验:通过关联关系查询销售台账的客户
                customerValue = inspect.getCustomer(); // 默认使用直接存储的客户
                if (inspect.getProductMainId() != null) {
                    // 通过报工ID查询工单
                    ProductionProductMain productMain = productionProductMainMapper.selectById(inspect.getProductMainId());
                    if (productMain != null && productMain.getWorkOrderId() != null) {
                        ProductWorkOrder workOrder = productWorkOrderMapper.selectById(productMain.getWorkOrderId());
                        if (workOrder != null && workOrder.getProductOrderId() != null) {
                            ProductOrder productOrder = productOrderMapper.selectById(workOrder.getProductOrderId());
                            if (productOrder != null && productOrder.getSalesLedgerId() != null) {
                                SalesLedger salesLedger = salesLedgerMapper.selectById(productOrder.getSalesLedgerId());
                                if (salesLedger != null && salesLedger.getCustomerName() != null) {
                                    customerValue = salesLedger.getCustomerName();
                                }
                            }
                        }
                    }
                }
            }
            put("customer", customerValue);
                    put("inspectType", finalInspectType);
                    put("paramList", paramList);
                    put("checkTime", checkTimeStr);
@@ -216,4 +257,4 @@
        qualityInspectExportHandle.exportExcel(response, exportList, exportDTO.getInspectType());
    }
}
}