|
@@ -1,5 +1,8 @@
|
|
|
package org.jeecg.modules.billet.rollHeight.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
@@ -41,6 +44,7 @@ import java.text.DecimalFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* @Description: 轧钢高线
|
|
@@ -318,6 +322,33 @@ public class RollHeightServiceImpl extends ServiceImpl<RollHeightMapper, RollHei
|
|
|
//构造数据
|
|
|
Map<String, RollHeightHeatVO.RollHeightHeatNo> rollHeightMap = buildRollHeightHeatNoMap(list); // 根据高线明细构建
|
|
|
|
|
|
+ Map<String, RollHeightHeatVO.RollHeightHeatNo> coldRollHeightMap = buildColdRollHeightHeatNoMap(list); // 根据步进冷床,高线明细构建
|
|
|
+
|
|
|
+ List<RollHeightVO> resultList1 = handleRollHeightMap(rollHeightMap);
|
|
|
+
|
|
|
+ List<RollHeightVO> resultList2 = handleRollHeightMap(coldRollHeightMap);
|
|
|
+
|
|
|
+ // 使用 Stream.concat() 合并两个列表
|
|
|
+ resultList = Stream.concat(resultList1.stream(), resultList2.stream())
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ resultList.sort(Comparator.comparing(
|
|
|
+ vo -> vo.getHeatNoDetails() == null || vo.getHeatNoDetails().isEmpty()
|
|
|
+ ? null
|
|
|
+ : vo.getHeatNoDetails().stream()
|
|
|
+ .map(RollHeightVO.HeatNoDetail::getCreateTime)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .max(Comparator.naturalOrder())
|
|
|
+ .orElse(null),
|
|
|
+ Comparator.nullsLast(Comparator.reverseOrder())
|
|
|
+ ));
|
|
|
+
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<RollHeightVO> handleRollHeightMap(Map<String, RollHeightHeatVO.RollHeightHeatNo> rollHeightMap) {
|
|
|
+
|
|
|
+ List<RollHeightVO> resultList = new ArrayList<>();
|
|
|
// 1. 按炉号聚合高线数据到 StorageCenterHeatNoInvoicingVO
|
|
|
Map<String, RollHeightHeatVO> heatNoVOMap = new HashMap<>();
|
|
|
for (String heatNo : rollHeightMap.keySet()) {
|
|
@@ -424,19 +455,91 @@ public class RollHeightServiceImpl extends ServiceImpl<RollHeightMapper, RollHei
|
|
|
} else {
|
|
|
log.warn("allHeatNos 为空,未生成高线信息结果");
|
|
|
}
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, RollHeightHeatVO.RollHeightHeatNo> buildColdRollHeightHeatNoMap(List<BilletOriginalProductRecord> heightList) {
|
|
|
+ Map<String, RollHeightHeatVO.RollHeightHeatNo> resultMap = new HashMap<>();
|
|
|
+ Map<String, Integer> coldLengthCumulativeCountMap = new HashMap<>(); // 冷坯起始位置
|
|
|
+
|
|
|
+ for (BilletOriginalProductRecord record : heightList) {
|
|
|
+ RollHeightHeatVO.RollHeightHeatNo rollHeightHeatNo = new RollHeightHeatVO.RollHeightHeatNo();
|
|
|
+ List<RollHeightHeatVO.SizeDetail> sizeDetailsList = new ArrayList<>();
|
|
|
+ List<RollHeightHeatVO.RollSendDetail> rollSendDetailList = new ArrayList<>();
|
|
|
+ String brandNum = "";
|
|
|
+
|
|
|
+ if (record.getGrade() != null) {
|
|
|
+ brandNum = Optional.ofNullable(record.getGrade())
|
|
|
+ .map(bn -> sysDictService.queryDictTextByKey("billet_spec", bn))
|
|
|
+ .orElseGet(() -> sysDictService.queryDictTextByKey("billet_spec", "5"));
|
|
|
+ }
|
|
|
+
|
|
|
+ rollHeightHeatNo.setBrandNum(brandNum);
|
|
|
+
|
|
|
+ rollHeightHeatNo.setId(record.getId());
|
|
|
+ rollHeightHeatNo.setConfirmTime(record.getColdConfirmTime());
|
|
|
+
|
|
|
+ // 判断原始记录stackLength字段是否为空,不为空则有步进冷床json数据,并且stackingBhtcId等于9时。需要做拆分成单独的一条 凉坯装运单 记录。
|
|
|
+ // stackLength字段数据结构为:[{\"stackingCount\":24,\"stackingLength\":10680,\"stackingWeight\":58.056,\"stackingBhtcId\":\"9\"}],[{\"stackingCount\":24,\"stackingLength\":10680,\"stackingWeight\":58.056,\"stackingBhtcId\":\"9\"}]
|
|
|
+ String stackLengthJson = record.getStackLength();
|
|
|
+ if (StringUtils.isNotBlank(stackLengthJson)) {
|
|
|
+ try {
|
|
|
+ JSONArray jsonArray = JSON.parseArray(stackLengthJson);
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+ JSONObject item = jsonArray.getJSONObject(i);
|
|
|
+ Integer stackingLength = item.getInteger("stackingLength");
|
|
|
+ Integer stackingCount = item.getInteger("stackingCount");
|
|
|
+ BigDecimal stackingWeight = item.getBigDecimal("stackingWeight");
|
|
|
+ String bhtcId = item.getString("stackingBhtcId");
|
|
|
+ if (stackingCount != null && stackingCount > 0 && "9".equals(bhtcId)){
|
|
|
+ rollHeightHeatNo.setTotalAmount(stackingCount);
|
|
|
+ rollHeightHeatNo.setTotalWeight(stackingWeight);
|
|
|
+ String spec = "";
|
|
|
+ LambdaQueryWrapper<BilletRulerConfig> wrapper = new LambdaQueryWrapper<BilletRulerConfig>()
|
|
|
+ .eq(BilletRulerConfig::getLength, stackingLength);
|
|
|
+ BilletRulerConfig config = billetRulerConfigMapper.selectOne(wrapper);
|
|
|
+ if (config != null && config.getSpec() != null) {
|
|
|
+ spec = config.getSpec();
|
|
|
+ }
|
|
|
+
|
|
|
+ int count = stackingCount;
|
|
|
+ // 计算起始根数与终止根数
|
|
|
+ int lastEndAmount = coldLengthCumulativeCountMap.getOrDefault(stackingLength, 0);
|
|
|
+ int startAmount = lastEndAmount + 1;
|
|
|
+ int endAmount = lastEndAmount + count;
|
|
|
+ coldLengthCumulativeCountMap.put(String.valueOf(stackingLength), endAmount); // 更新累计值
|
|
|
+
|
|
|
+ // sizeDetail
|
|
|
+ RollHeightHeatVO.SizeDetail sizeDetail = new RollHeightHeatVO.SizeDetail();
|
|
|
+ sizeDetail.setSize(stackingLength);
|
|
|
+ sizeDetail.setSizeAmount(stackingCount);
|
|
|
+ sizeDetail.setSizeWeight(stackingWeight);
|
|
|
+ sizeDetail.setStartAmount(startAmount);
|
|
|
+ sizeDetail.setEndAmount(endAmount);
|
|
|
+ sizeDetailsList.add(sizeDetail);
|
|
|
+
|
|
|
+ // rollSendDetail
|
|
|
+ RollHeightHeatVO.RollSendDetail rollSendDetail = new RollHeightHeatVO.RollSendDetail();
|
|
|
+ rollSendDetail.setSize(stackingLength);
|
|
|
+ rollSendDetail.setAmount(stackingCount);
|
|
|
+ rollSendDetail.setWeight(stackingWeight);
|
|
|
+ rollSendDetail.setSpec(spec);
|
|
|
+ rollSendDetail.setCreateTime(record.getCreateTime());
|
|
|
+ rollSendDetailList.add(rollSendDetail);
|
|
|
+ }
|
|
|
+ rollHeightHeatNo.setSizeDetails(sizeDetailsList);
|
|
|
+ rollHeightHeatNo.setRollSendDetails(rollSendDetailList);
|
|
|
+ resultMap.put(record.getHeatNo(), rollHeightHeatNo);
|
|
|
+ }
|
|
|
+ }catch (Exception e) {
|
|
|
+ log.info("步进冷床JSON解析失败,数据:{}", stackLengthJson, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return resultMap;
|
|
|
|
|
|
- resultList.sort(Comparator.comparing(
|
|
|
- vo -> vo.getHeatNoDetails() == null || vo.getHeatNoDetails().isEmpty()
|
|
|
- ? null
|
|
|
- : vo.getHeatNoDetails().stream()
|
|
|
- .map(RollHeightVO.HeatNoDetail::getCreateTime)
|
|
|
- .filter(Objects::nonNull)
|
|
|
- .max(Comparator.naturalOrder())
|
|
|
- .orElse(null),
|
|
|
- Comparator.nullsLast(Comparator.reverseOrder())
|
|
|
- ));
|
|
|
|
|
|
- return resultList;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -502,8 +605,7 @@ public class RollHeightServiceImpl extends ServiceImpl<RollHeightMapper, RollHei
|
|
|
Map<String, RollHeightHeatVO.RollHeightHeatNo> resultMap = new HashMap<>();
|
|
|
Map<String, BigDecimal> lengthWeightCache = new HashMap<>();
|
|
|
Map<String, String> lengthSpecCache = new HashMap<>();
|
|
|
- Map<String, Integer> lengthCumulativeCountMap = new HashMap<>(); // 新增:记录每种定尺的累计终止根数
|
|
|
-
|
|
|
+ Map<String, Integer> lengthCumulativeCountMap = new HashMap<>(); // 新增:记录每种定尺的累计终止根数.
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
|
for (BilletOriginalProductRecord record : heightList) {
|