From 49e1bc66ebaf696ebd3fc3ed33d65c8795fd3cde Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期二, 01 七月 2025 18:05:12 +0800
Subject: [PATCH] 1.巡检定时任务 2.设备管理 3.文档查询

---
 main-business/src/main/java/com/ruoyi/business/service/impl/ProductionMasterServiceImpl.java |   35 ++++++++++++++++++++++++++++++-----
 1 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/ProductionMasterServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/ProductionMasterServiceImpl.java
index 4d3b647..4157611 100644
--- a/main-business/src/main/java/com/ruoyi/business/service/impl/ProductionMasterServiceImpl.java
+++ b/main-business/src/main/java/com/ruoyi/business/service/impl/ProductionMasterServiceImpl.java
@@ -12,12 +12,14 @@
 import com.ruoyi.business.mapper.*;
 import com.ruoyi.business.service.ProductionMasterService;
 import com.ruoyi.common.exception.base.BaseException;
+import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.bean.BeanUtils;
 import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
+import java.time.LocalDate;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -49,6 +51,32 @@
     public IPage<ProductionMasterDto> selectPMList(Page page, ProductionMasterDto productionMasterDto) {
         // 1. 鏋勫缓涓昏〃鏌ヨ鏉′欢
         LambdaQueryWrapper<ProductionMaster> masterQueryWrapper = new LambdaQueryWrapper<>();
+        String keyword = productionMasterDto.getSearchAll();
+        if (StringUtils.isNotBlank(keyword)) {
+            // 鏌ヨ鐓ょ鍚嶇О涓ā绯婂尮閰嶇殑coalId鍒楄〃
+            List<Long> matchedCoalIds = coalInfoMapper.selectList(
+                            new LambdaQueryWrapper<CoalInfo>().like(CoalInfo::getCoal, keyword)
+                    ).stream()
+                    .map(CoalInfo::getId)
+                    .toList();
+
+            // 缁勮鏌ヨ鏉′欢锛氱叅绉岻D鍦ㄥ尮閰嶇殑鍒楄〃涓�
+            // 濡傛灉 matchedCoalIds 涓虹┖锛岀洿鎺ヨ繑鍥� 0 鏉℃暟鎹紙鏋勯�犱竴涓笉鍙兘鎴愮珛鐨勬潯浠讹級
+            if (matchedCoalIds.isEmpty()) {
+                masterQueryWrapper.apply("1 = 0"); // 寮哄埗杩斿洖绌虹粨鏋�
+            }
+            // 濡傛灉鏈夊尮閰嶇殑 coalId锛屽垯鎸� coalId 鏌ヨ
+            else {
+                String ids = matchedCoalIds.stream()
+                        .map(String::valueOf)
+                        .collect(Collectors.joining(","));
+
+                masterQueryWrapper.apply(
+                        "{0} = ANY(string_to_array(coal_id, ','))",
+                        ids
+                );
+            }
+        }
 
         // 2. 鎵ц涓昏〃鍒嗛〉鏌ヨ
         IPage<ProductionMaster> entityPage = productionMasterMapper.selectPage(page, masterQueryWrapper);
@@ -77,7 +105,6 @@
         IPage<ProductionMasterDto> dtoPage = new Page<>();
         BeanUtils.copyProperties(entityPage, dtoPage, "records");
         dtoPage.setRecords(dtoList);
-
         return dtoPage;
     }
 
@@ -212,15 +239,12 @@
             coalIds.add(p.getCoalId());
         }
 
-        List<CoalInfo> coalInfos = coalInfoMapper.selectList(new LambdaQueryWrapper<CoalInfo>().in(CoalInfo::getId, coalIds));
-
         ProductionMaster master = new ProductionMaster();
         master.setProductionQuantity(totalQuantity);
         master.setTotalCost(totalCost);
         master.setLaborCost(totalLabor);
         master.setEnergyConsumptionCost(totalEnergy);
         master.setEquipmentDepreciation(totalDepreciation);
-        master.setCoal(coalInfos.stream().map(CoalInfo::getCoal).collect(Collectors.joining(",")));
         master.setCoalId(coalIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
 
         return master;
@@ -265,7 +289,8 @@
             pending.setSupplierName("鐢熶骇鍔犲伐鍏ュ簱");
             pending.setTotalPriceIncludingTax(p.getTotalCost());
             pending.setPriceIncludingTax(p.getPurchasePrice());
-            pending.setPriceIncludingTax(p.getPurchasePrice());
+            pending.setRegistrantId(p.getProducerId());
+            pending.setRegistrationDate(LocalDate.now());
             pendingInventoryMapper.insert(pending);
         }
     }

--
Gitblit v1.9.3