From 2da4c045299aad5898dea78d7c9371491ce2c155 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期三, 11 六月 2025 09:50:50 +0800
Subject: [PATCH] 文件上传模块
---
main-business/src/main/java/com/ruoyi/business/service/impl/OfficialInventoryServiceImpl.java | 77 ++++++++++++++++++++++++++++++++++++--
1 files changed, 73 insertions(+), 4 deletions(-)
diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/OfficialInventoryServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/OfficialInventoryServiceImpl.java
index fdc9186..7be4276 100644
--- a/main-business/src/main/java/com/ruoyi/business/service/impl/OfficialInventoryServiceImpl.java
+++ b/main-business/src/main/java/com/ruoyi/business/service/impl/OfficialInventoryServiceImpl.java
@@ -3,13 +3,25 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.basic.entity.CoalField;
+import com.ruoyi.basic.entity.CoalValue;
+import com.ruoyi.basic.mapper.CoalFieldMapper;
+import com.ruoyi.basic.mapper.CoalValueMapper;
import com.ruoyi.business.dto.OfficialInventoryDto;
import com.ruoyi.business.entity.OfficialInventory;
import com.ruoyi.business.mapper.OfficialInventoryMapper;
+import com.ruoyi.business.mapper.PendingInventoryMapper;
import com.ruoyi.business.service.OfficialInventoryService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.stereotype.Service;
+import com.ruoyi.common.utils.bean.BeanUtils;
import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
/**
* <p>
@@ -25,9 +37,66 @@
private final OfficialInventoryMapper officialInventoryMapper;
+ private final CoalValueMapper coalValueMapper;
+
+ private final CoalFieldMapper coalFieldMapper;
+
+ private final PendingInventoryMapper pendingInventoryMapper;
+
@Override
- public IPage<OfficialInventory> selectOfficialInventoryList(Page page, OfficialInventoryDto officialInventoryDto) {
+ public IPage<OfficialInventoryDto> selectOfficialInventoryList(Page page, OfficialInventoryDto officialInventoryDto) {
+
+ // 鍏堟煡鍑哄師濮嬫暟鎹紙OfficialInventory锛�
LambdaQueryWrapper<OfficialInventory> queryWrapper = new LambdaQueryWrapper<>();
- return officialInventoryMapper.selectPage(page, queryWrapper);
+ IPage<OfficialInventory> entityPage = officialInventoryMapper.selectPage(page, queryWrapper);
+
+ // 鍒涘缓涓�涓柊鐨� Dto 鍒嗛〉缁撴灉
+ IPage<OfficialInventoryDto> dtoPage = new Page<>();
+ BeanUtils.copyProperties(entityPage, dtoPage);
+
+ List<OfficialInventoryDto> dtoList = new ArrayList<>();
+
+ // 鏌ヨ鎵�鏈夊彲鐢ㄥ瓧娈碉紙CoalField锛�
+ List<CoalField> coalFields = coalFieldMapper.selectList(null);
+ List<String> allFieldNames = coalFields.stream()
+ .map(CoalField::getFields)
+ .distinct()
+ .collect(Collectors.toList());
+
+ // 閬嶅巻姣忔潯璁板綍锛岃繘琛岃浆鎹㈠苟濉厖 fields
+ for (OfficialInventory entity : entityPage.getRecords()) {
+ OfficialInventoryDto dto = new OfficialInventoryDto();
+ BeanUtils.copyProperties(entity, dto);
+
+ Long pendingId = entity.getPendingId();
+
+ // 鏌ヨ璇� pendingId 瀵瑰簲鐨� CoalValue 鏁版嵁
+ List<CoalValue> coalValues = coalValueMapper.selectList(
+ new LambdaQueryWrapper<CoalValue>().eq(CoalValue::getPlanId, pendingId)
+ );
+
+ // 鏋勫缓 Map<fieldName, value>
+ Map<String, String> fieldValueMap = coalValues.stream()
+ .collect(Collectors.toMap(
+ CoalValue::getFields,
+ CoalValue::getCoalValue,
+ (existing, replacement) -> existing // 閲嶅瀛楁淇濈暀绗竴涓�
+ ));
+
+ // 鏋勯�犳渶缁� fields 鍒楄〃锛屽寘鍚墍鏈夊瓧娈靛悕锛屽苟璁剧疆榛樿鍊� "-"
+ List<Map<String, String>> fields = new ArrayList<>();
+ for (String field : allFieldNames) {
+ Map<String, String> fieldMap = new HashMap<>();
+ fieldMap.put(field, fieldValueMap.getOrDefault(field, "-"));
+ fields.add(fieldMap);
+ }
+
+ // 璁剧疆鍒� DTO 涓�
+ dto.setFields(fields);
+ dtoList.add(dto);
+ }
+
+ dtoPage.setRecords(dtoList); // 璁剧疆杞崲鍚庣殑 DtoList
+ return dtoPage;
}
}
--
Gitblit v1.9.3