瀏覽代碼

原始记录查询推钢室界面查询01

qiangxuan 4 周之前
父節點
當前提交
6c3ceeadc3

+ 448 - 108
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetOriginalProductRecord/controller/BilletOriginalProductRecordController.java

@@ -7,6 +7,7 @@ import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 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.core.toolkit.IdWorker;
@@ -35,9 +36,7 @@ import org.jeecg.modules.billet.billetOriginalProductRecord.dto.LengthCountQuery
 import org.jeecg.modules.billet.billetOriginalProductRecord.entity.BilletOriginalProductRecord;
 import org.jeecg.modules.billet.billetOriginalProductRecord.service.IBilletOriginalProductRecordService;
 import org.jeecg.common.system.base.controller.JeecgController;
-import org.jeecg.modules.billet.billetOriginalProductRecord.vo.BilletDetailsInfo;
-import org.jeecg.modules.billet.billetOriginalProductRecord.vo.BilletStatisticsDetail;
-import org.jeecg.modules.billet.billetOriginalProductRecord.vo.LengthCountVO;
+import org.jeecg.modules.billet.billetOriginalProductRecord.vo.*;
 import org.jeecg.modules.billet.storageBill.entity.HeatsActualsInfo;
 import org.jeecg.modules.billet.storageBill.entity.StorageBillPrint;
 import org.jeecg.modules.billet.storageBill.service.IStorageBillPrintService;
@@ -509,6 +508,27 @@ public class BilletOriginalProductRecordController extends JeecgController<Bille
 						 // 保留 heatNo 为空或不在 excludeHeatNos 中的记录
 						 return heatNo == null || !excludeHeatNos.contains(heatNo);
 					 }).collect(Collectors.toList());
+			 // 4. 同步原始钢坯生产记录表中存在的炉号信息(热装hotChargeLength字段)
+			 billetOriginalProductRecordList.forEach(x -> {
+				 // 查询装运单打印表最新的数据,获取热装定尺
+				 String shiftAndShiftGroup = x.getShift() + "/" + x.getShiftGroup();
+				 String heatNo = x.getHeatNo();
+				 // 构建安全的 JSON 路径表达式
+				 String jsonPath = "$.\"" + heatNo + "\"";
+				 List<StorageBillPrint> storageBillPrintList = storageBillPrintService.list(
+						 new QueryWrapper<StorageBillPrint>()
+								 .lambda()
+								 .eq(StorageBillPrint::getCcmNo, x.getCcmNo())
+								 .eq(StorageBillPrint::getClasses, shiftAndShiftGroup) // 新增的条件
+								 .apply("JSON_EXTRACT(heat_no, '" + jsonPath + "') IS NOT NULL")
+				 );
+				 if (oConvertUtils.listIsNotEmpty(storageBillPrintList)){
+					 List<Map<String, Object>> finalResult = handleStorageBillPrintHotCharge(storageBillPrintList, heatNo);
+					 log.info("钢坯原始记录,获取最新装运单打印表信息: {}", JSON.toJSONString(finalResult));
+					 x.setHotChargeLength(JSON.toJSONString(finalResult));
+					 billetOriginalProductRecordService.updateById(x);
+				 }
+			 });
 		 }else {
 			 filteredBilletHotsendList = billetHotsendList;
 		 }
@@ -664,111 +684,10 @@ public class BilletOriginalProductRecordController extends JeecgController<Bille
 							 .apply("JSON_EXTRACT(heat_no, '" + jsonPath + "') IS NOT NULL")
 			 );
 			 if (oConvertUtils.listIsNotEmpty(storageBillPrintList)){
-				 List<Map<String, Object>> hotChargeList = new ArrayList<>();
-				 // 遍历列表,解析每个 heatNo JSON 并累加数量
-				 for (StorageBillPrint print : storageBillPrintList) {
-					 Map<String, Object> hotChargeMap = new HashMap<>();
-					 String jsonHeatNo = print.getHeatNo();
-
-					 // 初始化当前记录的数量和重量
-					 Integer currentCount = 0;
-					 BigDecimal currentWeight = BigDecimal.ZERO;
-					 // 处理可能包含逗号的定尺值
-					 String sizeValue = print.getSize();
-					 String lengthValue = "0"; // 默认值
-
-					 if (oConvertUtils.isNotEmpty(sizeValue)) {
-						 lengthValue = sizeValue.contains(",")
-								 ? sizeValue.split(",")[0]  // 提取第一个值
-								 : sizeValue;              // 否则使用原值
-					 }
-
-					 if (oConvertUtils.isNotEmpty(jsonHeatNo)) {
-						 try {
-							 // 解析 JSON 对象
-							 JSONObject heatNoJson = JSON.parseObject(jsonHeatNo);
-
-							 // 获取指定炉号对应的数量(如果存在)
-							 if (heatNoJson.containsKey(heatNo)) {
-								 Integer count = heatNoJson.getInteger(heatNo);
-								 if (count != null) {
-									 currentCount = count;
-									 // 使用 BigDecimal 计算重量,避免精度丢失
-									 BigDecimal size = new BigDecimal(lengthValue);
-									 BigDecimal factor = new BigDecimal("0.2265");
-									 currentWeight = size.divide(new BigDecimal("1000"), 4, RoundingMode.HALF_UP)
-											 .multiply(factor)
-											 .multiply(new BigDecimal(count))
-											 .setScale(4, RoundingMode.HALF_UP);
-								 }
-							 }
-						 } catch (Exception e) {
-							 log.error("解析 heatNo JSON 失败: {}", jsonHeatNo, e);
-							 continue; // 跳过当前记录
-						 }
-					 }
-
-					// 设置热装信息
-					 hotChargeMap.put("hotChargeLength", lengthValue);
-					 hotChargeMap.put("hotChargeTotalCount", currentCount);
-					 hotChargeMap.put("hotChargeTotalWeight", currentWeight.toPlainString());
-
-					 // 设置目的地简称(添加默认值)
-					 String destination = "未知";
-					 if ("棒二".equals(print.getDestination())) {
-						 destination = "roll_club_two";
-					 } else if ("棒三".equals(print.getDestination())) {
-						 destination = "roll_club_three";
-					 } else if ("上若".equals(print.getDestination())) {
-						 destination = "roll_out_shipp";
-					 }
-					 hotChargeMap.put("hotChargeDestination", destination);
-					 // 将当前记录的热装信息添加到列表
-					 hotChargeList.add(hotChargeMap);
-				 }
-				 // 按 hotChargeLength 和 hotChargeDestination 分组统计
-				 Map<String, Map<String, Object>> groupedResult = new HashMap<>();
-
-				 if (oConvertUtils.listIsNotEmpty(hotChargeList)) {
-					 for (Map<String, Object> item : hotChargeList) {
-						 // 使用 getOrDefault 避免空指针
-						 String length = (String) item.getOrDefault("hotChargeLength", "未知");
-						 String destination = (String) item.getOrDefault("hotChargeDestination", "未知");
-						 Integer count = (Integer) item.getOrDefault("hotChargeTotalCount", 0);
-						 BigDecimal weight = new BigDecimal(item.getOrDefault("hotChargeTotalWeight", "0").toString());
-
-						 // 构建分组键
-						 String groupKey = length + "_" + destination;
-
-						 // 初始化或获取分组统计结果
-						 groupedResult.computeIfAbsent(groupKey, k -> {
-							 Map<String, Object> groupData = new HashMap<>();
-							 groupData.put("hotChargeLength", length);
-							 groupData.put("hotChargeDestination", destination);
-							 groupData.put("totalCount", 0);
-							 groupData.put("totalWeight", BigDecimal.ZERO);
-							 return groupData;
-						 });
-
-						 // 累加数量和重量
-						 Map<String, Object> groupData = groupedResult.get(groupKey);
-						 Integer totalCount = (Integer) groupData.get("totalCount") + count;
-						 BigDecimal totalWeight = ((BigDecimal) groupData.get("totalWeight")).add(weight);
-
-						 groupData.put("totalCount", totalCount);
-						 groupData.put("totalWeight", totalWeight);
-
-					 }
-					 // 转换为列表并格式化重量
-					 List<Map<String, Object>> finalResult = groupedResult.values().stream()
-							 .peek(data -> {
-								 // 格式化重量为字符串,保留4位小数
-								 data.put("totalWeight", ((BigDecimal) data.get("totalWeight")).toPlainString());
-							 }).collect(Collectors.toList());
-					 // 使用结果...
-					 log.info("钢坯原始记录,热装打印表分组统计结果: {}", JSON.toJSONString(finalResult));
-					 heatsActualsInfo.setHotCharge(JSON.toJSONString(finalResult));
-				 }
+				 List<Map<String, Object>> finalResult = handleStorageBillPrintHotCharge(storageBillPrintList, heatNo);
+				 // 使用结果...
+				 log.info("钢坯原始记录,热装打印表分组统计结果: {}", JSON.toJSONString(finalResult));
+				 heatsActualsInfo.setHotCharge(JSON.toJSONString(finalResult));
 			 }
 
 			 // 按length字段分组,并统计每组的总数和总重
@@ -846,6 +765,113 @@ public class BilletOriginalProductRecordController extends JeecgController<Bille
 		 return heatsActualsInfoList;
 	 }
 
+	 private List<Map<String, Object>> handleStorageBillPrintHotCharge(List<StorageBillPrint> storageBillPrintList, String heatNo) {
+		 List<Map<String, Object>> hotChargeList = new ArrayList<>();
+		 List<Map<String, Object>> finalResult = new ArrayList<>();
+		 // 遍历列表,解析每个 heatNo JSON 并累加数量
+		 for (StorageBillPrint print : storageBillPrintList) {
+			 Map<String, Object> hotChargeMap = new HashMap<>();
+			 String jsonHeatNo = print.getHeatNo();
+
+			 // 初始化当前记录的数量和重量
+			 Integer currentCount = 0;
+			 BigDecimal currentWeight = BigDecimal.ZERO;
+			 // 处理可能包含逗号的定尺值
+			 String sizeValue = print.getSize();
+			 String lengthValue = "0"; // 默认值
+
+			 if (oConvertUtils.isNotEmpty(sizeValue)) {
+				 lengthValue = sizeValue.contains(",")
+						 ? sizeValue.split(",")[0]  // 提取第一个值
+						 : sizeValue;              // 否则使用原值
+			 }
+
+			 if (oConvertUtils.isNotEmpty(jsonHeatNo)) {
+				 try {
+					 // 解析 JSON 对象
+					 JSONObject heatNoJson = JSON.parseObject(jsonHeatNo);
+
+					 // 获取指定炉号对应的数量(如果存在)
+					 if (heatNoJson.containsKey(heatNo)) {
+						 Integer count = heatNoJson.getInteger(heatNo);
+						 if (count != null) {
+							 currentCount = count;
+							 // 使用 BigDecimal 计算重量,避免精度丢失
+							 BigDecimal size = new BigDecimal(lengthValue);
+							 BigDecimal factor = new BigDecimal("0.2265");
+							 currentWeight = size.divide(new BigDecimal("1000"), 4, RoundingMode.HALF_UP)
+									 .multiply(factor)
+									 .multiply(new BigDecimal(count))
+									 .setScale(4, RoundingMode.HALF_UP);
+						 }
+					 }
+				 } catch (Exception e) {
+					 log.error("解析 heatNo JSON 失败: {}", jsonHeatNo, e);
+					 continue; // 跳过当前记录
+				 }
+			 }
+
+			 // 设置热装信息
+			 hotChargeMap.put("hotChargeLength", lengthValue);
+			 hotChargeMap.put("hotChargeTotalCount", currentCount);
+			 hotChargeMap.put("hotChargeTotalWeight", currentWeight.toPlainString());
+
+			 // 设置目的地简称(添加默认值)
+			 String destination = "未知";
+			 if ("棒二".equals(print.getDestination())) {
+				 destination = "roll_club_two";
+			 } else if ("棒三".equals(print.getDestination())) {
+				 destination = "roll_club_three";
+			 } else if ("上若".equals(print.getDestination())) {
+				 destination = "roll_out_shipp";
+			 }
+			 hotChargeMap.put("hotChargeDestination", destination);
+			 // 将当前记录的热装信息添加到列表
+			 hotChargeList.add(hotChargeMap);
+		 }
+		 // 按 hotChargeLength 和 hotChargeDestination 分组统计
+		 Map<String, Map<String, Object>> groupedResult = new HashMap<>();
+
+		 if (oConvertUtils.listIsNotEmpty(hotChargeList)) {
+			 for (Map<String, Object> item : hotChargeList) {
+				 // 使用 getOrDefault 避免空指针
+				 String length = (String) item.getOrDefault("hotChargeLength", "未知");
+				 String destination = (String) item.getOrDefault("hotChargeDestination", "未知");
+				 Integer count = (Integer) item.getOrDefault("hotChargeTotalCount", 0);
+				 BigDecimal weight = new BigDecimal(item.getOrDefault("hotChargeTotalWeight", "0").toString());
+
+				 // 构建分组键
+				 String groupKey = length + "_" + destination;
+
+				 // 初始化或获取分组统计结果
+				 groupedResult.computeIfAbsent(groupKey, k -> {
+					 Map<String, Object> groupData = new HashMap<>();
+					 groupData.put("hotChargeLength", length);
+					 groupData.put("hotChargeDestination", destination);
+					 groupData.put("totalCount", 0);
+					 groupData.put("totalWeight", BigDecimal.ZERO);
+					 return groupData;
+				 });
+
+				 // 累加数量和重量
+				 Map<String, Object> groupData = groupedResult.get(groupKey);
+				 Integer totalCount = (Integer) groupData.get("totalCount") + count;
+				 BigDecimal totalWeight = ((BigDecimal) groupData.get("totalWeight")).add(weight);
+
+				 groupData.put("totalCount", totalCount);
+				 groupData.put("totalWeight", totalWeight);
+
+			 }
+			 // 转换为列表并格式化重量
+			 finalResult = groupedResult.values().stream()
+					 .peek(data -> {
+						 // 格式化重量为字符串,保留4位小数
+						 data.put("totalWeight", ((BigDecimal) data.get("totalWeight")).toPlainString());
+					 }).collect(Collectors.toList());
+		 }
+		 return finalResult;
+	 }
+
 	 @ApiOperation(value="钢坯棒一棒二棒三上若统计明细查询", notes="钢坯棒一棒二棒三上若统计明细查询")
 	 @GetMapping(value = "/queryBilletStatisticsDetailByCcmNo")
 	 public Result<List<BilletDetailsInfo>> queryBilletStatisticsDetailByCcmNo(@RequestParam(name="ccmNo") String ccmNo,
@@ -881,6 +907,319 @@ public class BilletOriginalProductRecordController extends JeecgController<Bille
 		 return Result.OK(billetDetailsInfoList);
 	 }
 
+	 @ApiOperation(value="推钢室当班炉次浇筑信息查询", notes="推钢室当班炉次浇筑信息查询")
+	 @GetMapping(value = "/queryOriginalHeatInfoByCcmNo")
+	 public Result<BilletOriginalInfo> queryHeatsActualsByCcmNo(@RequestParam(name="ccmNo", required = false) String ccmNo) {
+		 BilletOriginalInfo billetOriginalInfo = new BilletOriginalInfo();
+		 String classShiftGroup = String.format("class:shift:group:%s", ccmNo); // 班组
+		 String classShift = String.format("class:shift:%s",ccmNo); // 班别
+		 String shift = !oConvertUtils.getString(redisTemplate.opsForValue().get(classShift)).isEmpty() ? oConvertUtils.getString(redisTemplate.opsForValue().get(classShift)) : "";
+		 String shiftGroup = !oConvertUtils.getString(redisTemplate.opsForValue().get(classShiftGroup)).isEmpty() ? oConvertUtils.getString(redisTemplate.opsForValue().get(classShiftGroup)) : "";
+
+		 if (oConvertUtils.isEmpty(shiftGroup) || oConvertUtils.isEmpty(shift)){
+			 return Result.error("班组班别获取为空,查询失败!");
+		 }
+		// 根据ccmNo、shift、shiftGroup查询最新的交班记录
+		 LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapper = new LambdaQueryWrapper<>();
+		 queryWrapper.eq(BilletHotsendChangeShift::getCcmNo, ccmNo)
+				 .eq(BilletHotsendChangeShift::getShift, shift)
+				 .eq(BilletHotsendChangeShift::getShiftGroup, shiftGroup)
+				 .isNull(BilletHotsendChangeShift::getChangeShiftTime)
+				 .orderByDesc(BilletHotsendChangeShift::getCreateTime)
+				 .last("limit 1");
+		 BilletHotsendChangeShift billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapper);
+		 if (billetHotsendChangeShift == null){
+			 return Result.error("交班记录为空,查询失败!");
+		 }
+
+		 Date startTime = billetHotsendChangeShift.getCreateTime();
+		 Date endTime = new Date();
+
+		 // 通过铸机号、开始时间、结束时间查询 钢坯原始生产记录
+		 QueryWrapper<BilletOriginalProductRecord> queryWrapper1 = new QueryWrapper<>();
+		 queryWrapper1.eq("ccm_no", ccmNo);
+		 queryWrapper1.eq("shift", shift);
+		 queryWrapper1.eq("shift_group", shiftGroup);
+		 queryWrapper1.between("create_time", startTime, endTime);
+		 queryWrapper1.orderByDesc("create_time");
+		 List<BilletOriginalProductRecord> billetOriginalProductRecordList = billetOriginalProductRecordService.list(queryWrapper1);
+		 if (oConvertUtils.listIsEmpty(billetOriginalProductRecordList)){
+			 return Result.OK(billetOriginalInfo);
+		 }
+		 String directRollingJson = calculateDirectRollingStatistics(billetOriginalProductRecordList);
+		 // 统计直轧棒一
+		 billetOriginalInfo.setDirectRolling(directRollingJson);
+
+		 // 根据铸机号、开始时间、结束时间查询查询装运单打印表
+		 String hotChargeJson = "";
+		 String shiftAndShiftGroup = shift + "/" + shiftGroup;
+		 LambdaQueryWrapper<StorageBillPrint> querySbWrapper = new LambdaQueryWrapper<>();
+		 querySbWrapper.eq(StorageBillPrint::getCcmNo, ccmNo)
+				 .eq(StorageBillPrint::getClasses, shiftAndShiftGroup)
+				 .between(StorageBillPrint::getCreateTime, startTime, endTime)
+				 .orderByDesc(StorageBillPrint::getCreateTime);
+		 List<StorageBillPrint> storageBillPrintList = storageBillPrintService.list(querySbWrapper);
+		 if (oConvertUtils.listIsNotEmpty(storageBillPrintList)) {
+			 hotChargeJson = calculateHotChargeStatistics(storageBillPrintList);
+		     // 统计热装
+			 billetOriginalInfo.setHotCharge(hotChargeJson);
+		 }
+		 String stackingJson = calculateStackingStatistics(billetOriginalProductRecordList);
+		 // 统计堆垛
+		 billetOriginalInfo.setStacking(stackingJson);
+
+		 // 计算总重量
+		 double totalWeight = calculateTotalWeight(directRollingJson, hotChargeJson, stackingJson);
+		 billetOriginalInfo.setBlankOutputs(totalWeight);
+
+		 billetOriginalInfo.setShift(shift);
+		 billetOriginalInfo.setShiftGroup(shiftGroup);
+		 billetOriginalInfo.setBilletOriginalProductRecordList(billetOriginalProductRecordList);
+		 billetOriginalInfo.setTotalInfo(billetOriginalProductRecordList.size());
+		 return Result.OK(billetOriginalInfo);
+	 }
+	 /**
+	  * 计算直轧棒一的统计信息
+	  */
+	 private String calculateDirectRollingStatistics(List<BilletOriginalProductRecord> records) {
+		 // 用于存储统计结果的Map,键为定尺,值为数量和重量
+		 Map<String, LengthStatistics> lengthStatsMap = new HashMap<>();
+
+		 // 遍历所有记录
+		 for (BilletOriginalProductRecord record : records) {
+			 String rollClubOneDetails = record.getRollClubOneDetails();
+			 if (oConvertUtils.isNotEmpty(rollClubOneDetails)) {
+				 try {
+					 // 解析JSON字符串
+					 JSONObject detailsJson = JSON.parseObject(rollClubOneDetails);
+					 // 获取lengthGroupCount对象
+					 JSONObject lengthGroupCount = detailsJson.getJSONObject("lengthGroupCount");
+					 if (lengthGroupCount != null) {
+						 // 遍历每个定尺及其数量
+						 for (Map.Entry<String, Object> entry : lengthGroupCount.entrySet()) {
+							 String length = entry.getKey();
+							 Integer count = Integer.valueOf(entry.getValue().toString());
+							 // 累加到统计结果中
+							 lengthStatsMap.computeIfAbsent(length, k -> new LengthStatistics()).addCount(count);
+						 }
+					 }
+				 } catch (Exception e) {
+					 log.error("解析rollClubOneDetails失败: {}", rollClubOneDetails, e);
+					 // 忽略解析失败的记录,继续处理其他记录
+				 }
+			 }
+		 }
+
+		 // 计算总重量并构建结果
+		 JSONObject resultJson = new JSONObject();
+		 JSONObject lengthGroupCountJson = new JSONObject();
+		 BigDecimal totalWeight = BigDecimal.ZERO;
+		 int totalCount = 0;
+
+		 // 计算每个定尺的重量并累加总重量
+		 for (Map.Entry<String, LengthStatistics> entry : lengthStatsMap.entrySet()) {
+			 String length = entry.getKey();
+			 LengthStatistics stats = entry.getValue();
+
+			 // 计算当前定尺的总重量
+			 BigDecimal size = new BigDecimal(length);
+			 BigDecimal weight = size.divide(new BigDecimal("1000"), 4, RoundingMode.HALF_UP)
+					 .multiply(new BigDecimal(stats.getCount()))
+					 .multiply(new BigDecimal("0.2265"))
+					 .setScale(4, RoundingMode.HALF_UP);
+
+			 // 更新统计信息
+			 stats.setWeight(weight);
+			 totalWeight = totalWeight.add(weight);
+			 totalCount += stats.getCount();
+
+			 // 构建定尺统计JSON
+			 JSONObject lengthStatsJson = new JSONObject();
+			 lengthStatsJson.put("count", stats.getCount());
+			 lengthStatsJson.put("weight", weight.toPlainString());
+			 lengthGroupCountJson.put(length, lengthStatsJson);
+		 }
+
+		 // 设置最终结果
+		 resultJson.put("lengthGroupCount", lengthGroupCountJson);
+		 resultJson.put("directRollingTotalCount", totalCount);
+		 resultJson.put("directRollingTotalWeight", totalWeight.toPlainString());
+
+		 return resultJson.toJSONString();
+	 }
+
+	 /**
+	  * 计算热装的统计信息
+	  */
+	 private String calculateHotChargeStatistics(List<StorageBillPrint> storageBillPrintList) {
+		 // 用于存储统计结果的Map,键为size,值为统计信息
+		 Map<String, SizeStatistics> sizeStatsMap = new HashMap<>();
+
+		 // 遍历所有记录
+		 for (StorageBillPrint print : storageBillPrintList) {
+			 String size = print.getSize();
+			 if (oConvertUtils.isNotEmpty(size)) {
+				 try {
+					 // 转换为数值并验证
+					 BigDecimal sizeDecimal = new BigDecimal(size.trim());
+
+					 // 累加数量和计算重量
+					 sizeStatsMap.computeIfAbsent(size, k -> new SizeStatistics())
+							 .addData(1, calculateWeight(sizeDecimal, 1));
+				 } catch (NumberFormatException e) {
+					 log.error("无效的size值: {}", size, e);
+					 // 忽略无效的size值,继续处理其他值
+				 }
+			 }
+		 }
+
+		 // 构建结果JSON (保持原有逻辑不变)
+		 JSONObject resultJson = new JSONObject();
+		 JSONObject sizeGroupJson = new JSONObject();
+		 int totalCount = 0;
+		 BigDecimal totalWeight = BigDecimal.ZERO;
+
+		 // 处理统计结果
+		 for (Map.Entry<String, SizeStatistics> entry : sizeStatsMap.entrySet()) {
+			 String size = entry.getKey();
+			 SizeStatistics stats = entry.getValue();
+
+			 // 构建单个size的统计JSON
+			 JSONObject sizeStatsJson = new JSONObject();
+			 sizeStatsJson.put("count", stats.getCount());
+			 sizeStatsJson.put("weight", stats.getWeight().toPlainString());
+
+			 // 添加到结果中
+			 sizeGroupJson.put(size, sizeStatsJson);
+			 totalCount += stats.getCount();
+			 totalWeight = totalWeight.add(stats.getWeight());
+		 }
+
+		 // 设置最终结果
+		 resultJson.put("sizeGroupCount", sizeGroupJson);
+		 resultJson.put("totalCount", totalCount);
+		 resultJson.put("totalWeight", totalWeight.toPlainString());
+		 return resultJson.toJSONString();
+	 }
+	 /**
+	  * 计算堆垛信息的统计
+	  */
+	 private String calculateStackingStatistics(List<BilletOriginalProductRecord> records) {
+		 // 用于存储统计结果的Map,键为定尺,值为统计信息
+		 Map<String, SizeStatistics> stackingStatsMap = new HashMap<>();
+
+		 // 遍历所有记录
+		 for (BilletOriginalProductRecord record : records) {
+			 String stackLengthJson = record.getStackLength();
+			 if (oConvertUtils.isNotEmpty(stackLengthJson)) {
+				 try {
+					 // 解析JSON数组
+					 JSONArray stackLengthArray = JSON.parseArray(stackLengthJson);
+
+					 // 遍历每个堆垛信息
+					 for (int i = 0; i < stackLengthArray.size(); i++) {
+						 JSONObject stackItem = stackLengthArray.getJSONObject(i);
+
+						 // 获取堆垛长度和数量
+						 String length = stackItem.getString("stackingLength");
+						 Integer count = stackItem.getInteger("stackingCount");
+						 BigDecimal weight = stackItem.getBigDecimal("stackingWeight");
+
+						 if (length != null && count != null && weight != null) {
+							 // 累加到统计结果中
+							 stackingStatsMap.computeIfAbsent(length, k -> new SizeStatistics()).addData(count, weight);
+						 }
+					 }
+				 } catch (Exception e) {
+					 log.error("解析stackLength失败: {}", stackLengthJson, e);
+					 // 忽略解析失败的记录,继续处理其他记录
+				 }
+			 }
+		 }
+
+		 // 构建结果JSON
+		 JSONObject resultJson = new JSONObject();
+		 JSONObject lengthGroupJson = new JSONObject();
+		 int totalCount = 0;
+		 BigDecimal totalWeight = BigDecimal.ZERO;
+
+		 // 处理统计结果
+		 for (Map.Entry<String, SizeStatistics> entry : stackingStatsMap.entrySet()) {
+			 String length = entry.getKey();
+			 SizeStatistics stats = entry.getValue();
+
+			 // 构建单个定尺的统计JSON
+			 JSONObject lengthStatsJson = new JSONObject();
+			 lengthStatsJson.put("count", stats.getCount());
+			 lengthStatsJson.put("weight", stats.getWeight().toPlainString());
+
+			 // 添加到结果中
+			 lengthGroupJson.put(length, lengthStatsJson);
+			 totalCount += stats.getCount();
+			 totalWeight = totalWeight.add(stats.getWeight());
+		 }
+
+		 // 设置最终结果
+		 resultJson.put("lengthGroupCount", lengthGroupJson);
+		 resultJson.put("stackingTotalCount", totalCount);
+		 resultJson.put("stackingTotalWeight", totalWeight.toPlainString());
+
+		 return resultJson.toJSONString();
+	 }
+	 /**
+	  * 从三个JSON中提取总重量并计算总和
+	  */
+	 private double calculateTotalWeight(String directRollingJson, String hotChargeJson, String stackingJson) {
+		 BigDecimal total = BigDecimal.ZERO;
+		 // 从直轧统计中提取总重量
+		 if (oConvertUtils.isNotEmpty(directRollingJson)) {
+			 try {
+				 JSONObject json = JSON.parseObject(directRollingJson);
+				 String weightStr = json.getString("directRollingTotalWeight");
+				 if (oConvertUtils.isNotEmpty(weightStr)) {
+					 total = total.add(new BigDecimal(weightStr));
+				 }
+			 } catch (Exception e) {
+				 log.error("从directRollingJson提取总重量失败", e);
+			 }
+		 }
+
+		 // 从热装统计中提取总重量
+		 if (oConvertUtils.isNotEmpty(hotChargeJson)) {
+			 try {
+				 JSONObject json = JSON.parseObject(hotChargeJson);
+				 String weightStr = json.getString("totalWeight");
+				 if (oConvertUtils.isNotEmpty(weightStr)) {
+					 total = total.add(new BigDecimal(weightStr));
+				 }
+			 } catch (Exception e) {
+				 log.error("从hotChargeJson提取总重量失败", e);
+			 }
+		 }
+
+		 // 从堆垛统计中提取总重量
+		 if (oConvertUtils.isNotEmpty(stackingJson)) {
+			 try {
+				 JSONObject json = JSON.parseObject(stackingJson);
+				 String weightStr = json.getString("stackingTotalWeight");
+				 if (oConvertUtils.isNotEmpty(weightStr)) {
+					 total = total.add(new BigDecimal(weightStr));
+				 }
+			 } catch (Exception e) {
+				 log.error("从stackingJson提取总重量失败", e);
+			 }
+		 }
+		 // 转换为double类型,保留4位小数
+		 return total.setScale(4, RoundingMode.HALF_UP).doubleValue();
+	 }
+	 // 保持原有计算方法不变
+	 private BigDecimal calculateWeight(BigDecimal size, int count) {
+		 return size.divide(new BigDecimal("1000"), 4, RoundingMode.HALF_UP)
+				 .multiply(new BigDecimal(count))
+				 .multiply(new BigDecimal("0.2265"))
+				 .setScale(4, RoundingMode.HALF_UP);
+	 }
+
 	 /**
 	  * 棒一统计明细查询
 	  * @param ccmNo
@@ -950,6 +1289,7 @@ public class BilletOriginalProductRecordController extends JeecgController<Bille
 
 		 return billetDetailsInfoList;
 	 }
+
 	 /**
 	  * 棒一统计明细查询
 	  * @param ccmNo

+ 31 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetOriginalProductRecord/vo/BilletOriginalInfo.java

@@ -0,0 +1,31 @@
+package org.jeecg.modules.billet.billetOriginalProductRecord.vo;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.jeecg.modules.billet.billetOriginalProductRecord.entity.BilletOriginalProductRecord;
+import java.util.List;
+
+@Data
+public class BilletOriginalInfo {
+
+    private List<BilletOriginalProductRecord> billetOriginalProductRecordList;
+
+    @ApiModelProperty(value = "直轧")
+    private String directRolling;
+
+    @ApiModelProperty(value = "热装")
+    private String hotCharge;
+
+    @ApiModelProperty(value = "堆垛")
+    private String stacking;
+
+    @ApiModelProperty(value = "总支数")
+    private Integer totalInfo;
+
+    @ApiModelProperty(value = "总重量")
+    private double blankOutputs;
+
+    /**班组*/
+    private String shiftGroup;
+    /**班别*/
+    private String shift;
+}

+ 24 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetOriginalProductRecord/vo/LengthStatistics.java

@@ -0,0 +1,24 @@
+package org.jeecg.modules.billet.billetOriginalProductRecord.vo;
+
+import java.math.BigDecimal;
+
+public class LengthStatistics {
+    private int count = 0;
+    private BigDecimal weight = BigDecimal.ZERO;
+
+    public void addCount(int count) {
+        this.count += count;
+    }
+
+    public int getCount() {
+        return count;
+    }
+
+    public BigDecimal getWeight() {
+        return weight;
+    }
+
+    public void setWeight(BigDecimal weight) {
+        this.weight = weight;
+    }
+}

+ 24 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetOriginalProductRecord/vo/SizeStatistics.java

@@ -0,0 +1,24 @@
+package org.jeecg.modules.billet.billetOriginalProductRecord.vo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+
+public class SizeStatistics {
+    private int count = 0;
+    private BigDecimal weight = BigDecimal.ZERO;
+
+    public void addData(int count, BigDecimal weight) {
+        this.count += count;
+        this.weight = this.weight.add(weight);
+    }
+
+    public int getCount() {
+        return count;
+    }
+
+    public BigDecimal getWeight() {
+        return weight.setScale(4, RoundingMode.HALF_UP);
+    }
+}