Commit cd512ccf by jiang'yun

修改

parent 086d6e0f
package com.ruoyi.project.zjsgfa.controller; package com.ruoyi.project.zjsgfa.controller;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -39,11 +40,11 @@ public class SjZjyFdxnbController extends BaseController ...@@ -39,11 +40,11 @@ public class SjZjyFdxnbController extends BaseController
*/ */
//@PreAuthorize("@ss.hasPermi('system:sjZjyFdxnb:list')") //@PreAuthorize("@ss.hasPermi('system:sjZjyFdxnb:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(SjZjyFdxnb sjZjyFdxnb) public AjaxResult list(SjZjyFdxnb sjZjyFdxnb)
{ {
// startPage(); // startPage();
List<SjZjyFdxnb> list = sjZjyFdxnbService.selectSjZjyFdxnbList(sjZjyFdxnb); Map<String, Object> list = sjZjyFdxnbService.selectSjZjyFdxnbList(sjZjyFdxnb);
return getDataTable(list); return AjaxResult.success(list);
} }
/** /**
...@@ -54,9 +55,9 @@ public class SjZjyFdxnbController extends BaseController ...@@ -54,9 +55,9 @@ public class SjZjyFdxnbController extends BaseController
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, SjZjyFdxnb sjZjyFdxnb) public void export(HttpServletResponse response, SjZjyFdxnb sjZjyFdxnb)
{ {
List<SjZjyFdxnb> list = sjZjyFdxnbService.selectSjZjyFdxnbList(sjZjyFdxnb); // List<SjZjyFdxnb> list = sjZjyFdxnbService.selectSjZjyFdxnbList(sjZjyFdxnb);
ExcelUtil<SjZjyFdxnb> util = new ExcelUtil<SjZjyFdxnb>(SjZjyFdxnb.class); // ExcelUtil<SjZjyFdxnb> util = new ExcelUtil<SjZjyFdxnb>(SjZjyFdxnb.class);
util.exportExcel(response, list, "设计信息-分段钻井液性能设计数据"); // util.exportExcel(response, list, "设计信息-分段钻井液性能设计数据");
} }
/** /**
......
package com.ruoyi.project.zjsgfa.service; package com.ruoyi.project.zjsgfa.service;
import java.util.List; import java.util.List;
import java.util.Map;
import com.ruoyi.project.zjsgfa.domain.SjZjyFdxnb; import com.ruoyi.project.zjsgfa.domain.SjZjyFdxnb;
/** /**
...@@ -25,7 +27,7 @@ public interface ISjZjyFdxnbService ...@@ -25,7 +27,7 @@ public interface ISjZjyFdxnbService
* @param sjZjyFdxnb 设计信息-分段钻井液性能设计 * @param sjZjyFdxnb 设计信息-分段钻井液性能设计
* @return 设计信息-分段钻井液性能设计集合 * @return 设计信息-分段钻井液性能设计集合
*/ */
public List<SjZjyFdxnb> selectSjZjyFdxnbList(SjZjyFdxnb sjZjyFdxnb); public Map<String, Object> selectSjZjyFdxnbList(SjZjyFdxnb sjZjyFdxnb);
/** /**
* 新增设计信息-分段钻井液性能设计 * 新增设计信息-分段钻井液性能设计
......
package com.ruoyi.project.zjsgfa.service.impl; package com.ruoyi.project.zjsgfa.service.impl;
import java.util.List; import java.lang.reflect.Field;
import java.util.*;
import java.util.stream.Collectors;
import com.mchange.v1.identicator.IdList;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -39,9 +43,68 @@ public class SjZjyFdxnbServiceImpl implements ISjZjyFdxnbService ...@@ -39,9 +43,68 @@ public class SjZjyFdxnbServiceImpl implements ISjZjyFdxnbService
* @return 设计信息-分段钻井液性能设计 * @return 设计信息-分段钻井液性能设计
*/ */
@Override @Override
public List<SjZjyFdxnb> selectSjZjyFdxnbList(SjZjyFdxnb sjZjyFdxnb) public Map<String, Object> selectSjZjyFdxnbList(SjZjyFdxnb sjZjyFdxnb)
{ {
return sjZjyFdxnbMapper.selectSjZjyFdxnbList(sjZjyFdxnb); List<SjZjyFdxnb> list = sjZjyFdxnbMapper.selectSjZjyFdxnbList(sjZjyFdxnb);
List<Map<String, String>> fixedItems = Arrays.asList(
new HashMap<String, String>() {{ put("name", "密度(g/cm³)"); put("field", "md"); }},
new HashMap<String, String>() {{ put("name", "马氏漏斗黏度(s)"); put("field", "msldnd"); }},
new HashMap<String, String>() {{ put("name", "API滤失量(ml)"); put("field", "apilsl"); }},
new HashMap<String, String>() {{ put("name", "API泥饼(mm)"); put("field", "apinb"); }},
new HashMap<String, String>() {{ put("name", "静切力(Pa)"); put("field", "jql"); }},
new HashMap<String, String>() {{ put("name", "pH值"); put("field", "ph"); }},
new HashMap<String, String>() {{ put("name", "含砂量(%)"); put("field", "hsl"); }},
new HashMap<String, String>() {{ put("name", "总固含(%)"); put("field", "zgh"); }},
new HashMap<String, String>() {{ put("name", "摩阻系数"); put("field", "mzxs"); }},
new HashMap<String, String>() {{ put("name", "动切力(Pa)"); put("field", "dql"); }},
new HashMap<String, String>() {{ put("name", "塑性黏度(mPa·s)"); put("field", "sxnd"); }}
);
// 提取井段(去重,按顺序排列)
List<String> wellSegments = list.stream()
.map(SjZjyFdxnb::getJd)
.distinct()
.collect(Collectors.toList());
// 表格数据:每行对应一个固定项目,每列对应一个井段
List<Map<String, String>> tableData = new ArrayList<>();
for (Map<String, String> item : fixedItems) {
String itemName = item.get("name"); // 项目名称(如"密度(g/cm³)")
String fieldName = item.get("field"); // 实体类字段名(如"md")
Map<String, String> row = new HashMap<>();
row.put("项目", itemName); // 第一列固定为项目名称
// 遍历每个井段,填充对应字段的值
for (String segment : wellSegments) {
// 找到当前井段的数据对象
SjZjyFdxnb segmentData = list.stream()
.filter(d -> segment.equals(d.getJd()))
.findFirst()
.orElse(null);
// 通过反射获取字段值(避免大量if-else)
String value = "";
if (segmentData != null) {
try {
Field field = SjZjyFdxnb.class.getDeclaredField(fieldName);
field.setAccessible(true);
Object fieldValue = field.get(segmentData);
value = fieldValue != null ? fieldValue.toString() : "";
} catch (Exception e) {
value = "";
}
}
row.put(segment, value); // 列名为井段,值为字段值
}
tableData.add(row);
}
Map<String,Object> map =new HashMap<>();
map.put("jds",wellSegments);
map.put("data",tableData);
return map;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment