Commit f0a28110 by lijingjing

调整统计业务处理逻辑;

parent eba5d3bc
......@@ -3,6 +3,7 @@ package com.patzn.cloud.service.lims.hmhj.service.impl;
import com.baomidou.mybatisplus.toolkit.CollectionUtils;
import com.patzn.cloud.commons.api.RestAssert;
import com.patzn.cloud.commons.service.impl.BaseServiceImpl;
import com.patzn.cloud.commons.toolkit.MapMergeUtils;
import com.patzn.cloud.service.hmhj.dto.LedgerQueryDTO;
import com.patzn.cloud.service.hmhj.dto.QueryDTO;
import com.patzn.cloud.service.hmhj.dto.RangeStatsQueryDTO;
......@@ -338,10 +339,23 @@ public class StatisticsServiceImpl extends BaseServiceImpl<StatisticsMapper, Sta
isNumber = null != isNumber && isNumber;
// 查询出传递月份所有日期
List<String> dateList = DateKit.dateInMonth(yearMonth);
// 查询出所有label值
List<String> labels = list.stream().map(DailyStatsLedgerVO::getLabel).distinct().collect(Collectors.toList());
// 查询出主名称
List<String> names = list.stream().map(DailyStatsLedgerVO::getName).distinct().collect(Collectors.toList());
// 查询出所有label值,查询出主名称
List<String> labels = new ArrayList<>(), names = new ArrayList<>();
// 定义label list map
Map<String, List<DailyStatsLedgerVO>> labelMap = new HashMap<>(16);
for (DailyStatsLedgerVO vo : list) {
if (!labels.contains(vo.getLabel())) {
labels.add(vo.getLabel());
}
if (!names.contains(vo.getName())) {
names.add(vo.getName());
}
// label map
MapMergeUtils.getorCreateMapArrayList(vo.getLabel(), labelMap, vo);
}
// 是否包含主类别
boolean isIncName = CollectionUtils.isNotEmpty(names);
......@@ -350,8 +364,9 @@ public class StatisticsServiceImpl extends BaseServiceImpl<StatisticsMapper, Sta
Boolean finalIsNumber = isNumber;
return labels.stream().map(l -> {
// 此处过滤一边所有值中对应label的数据
List<DailyStatsLedgerVO> values = list.stream().filter(t -> t.getLabel().equals(l)).collect(Collectors.toList());
Map<String, Object> dataMap = new HashMap<>();
// 原逻辑:values = list.stream().filter(t -> t.getLabel().equals(l)).collect(Collectors.toList())
List<DailyStatsLedgerVO> values = labelMap.get(l);
Map<String, Object> dataMap = new HashMap<>(4);
dataMap.put("label", getDataLabel(l, names));
if (isIncName) {
dataMap.put("name", getDataName(l, names));
......@@ -359,7 +374,7 @@ public class StatisticsServiceImpl extends BaseServiceImpl<StatisticsMapper, Sta
dataMap.put("data", dateList.stream().map(d -> {
String value = finalIsNumber ? "0" : "";
// 根据日期过滤对应的值
Optional<DailyStatsLedgerVO> optional = values.stream().filter(f -> f.getDay().equals(d)).findFirst();
Optional<DailyStatsLedgerVO> optional = values.stream().filter(f -> Objects.equals(f.getDay(), d)).findFirst();
if (optional.isPresent()) {
value = optional.get().getValue();
}
......
......@@ -709,7 +709,7 @@
AND s.NAME = '原铝'
AND s.sample_grading IS NOT NULL
AND to_char(i.test_time,'yyyy-mm') = #{vo.yearMonth}
AND TRIM(ii.test_value) ~ '^([-]?[0-9]+[.]?[0-9]*|[.][0-9]+)$'
AND TRIM(ii.test_value) ~ '^([0-9]+[.]?[0-9]+)$'
<include refid="ledger_where"/>
GROUP BY s.id
ORDER BY s.slot_no, "day"
......@@ -759,7 +759,7 @@
i.deleted = 0
AND i.NAME IN ( '原铝Fe', '原铝Ni')
AND to_char(i.test_time,'yyyy-mm') = #{vo.yearMonth}
AND (TRIM(ii.test_value) ~ '^([-]?[0-9]+[.]?[0-9]*|[.][0-9]+)$')
AND (TRIM(ii.test_value) ~ '^([0-9]+[.]?[0-9]*|[.][0-9]+)$')
GROUP BY
i.entrust_sample_id
) i ON i.entrust_sample_id = s.ID
......@@ -799,7 +799,7 @@
i.deleted = 0
AND s.NAME in ('原铝','原铝散样','原铝重取')
AND to_char( i.test_time, 'yyyy-mm') = #{vo.yearMonth}
AND (TRIM(ii.test_value) ~ '^([-]?[0-9]+[.]?[0-9]+)$')
AND (TRIM(ii.test_value) ~ '^([0-9]+[.]?[0-9]+)$')
<include refid="ledger_where"/>
GROUP BY
i.NAME, "test_time"
......
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