Răsfoiți Sursa

高线工作台凉坯拆分、确认凉坯打印单01

qiangxuan 1 zi în urmă
părinte
comite
d46072d976

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

@@ -430,6 +430,47 @@ public class BilletOriginalProductRecordController extends JeecgController<Bille
 		stackingAndLoadingVehiclesMapper.update(null, updateWrapper);
 	}
 
+	private void clearColdStackByHeatNo(String ccmNo, String heatNo, String size, String typeConfigId, int amount) {
+		if (oConvertUtils.isEmpty(ccmNo) || oConvertUtils.isEmpty(heatNo) || oConvertUtils.isEmpty(typeConfigId) || oConvertUtils.isEmpty(size)){
+			log.info("{}{}", "清空指定炉已经起垛的数据时参数为空:", ccmNo + ">|<" + heatNo + ">|<" + size + ">|<" + typeConfigId);
+			return;
+		}
+
+		// 根据ccmNo、heatNo、typeConfigId查询出已经起垛的记录
+		LambdaQueryWrapper<StackingAndLoadingVehicles> queryWrapper = new LambdaQueryWrapper<>();
+		queryWrapper.eq(StackingAndLoadingVehicles::getCcmNo, ccmNo)
+				.eq(StackingAndLoadingVehicles::getHeatNo, heatNo)
+				.eq(StackingAndLoadingVehicles::getSize, size)
+				.eq(StackingAndLoadingVehicles::getTypeConfigId, typeConfigId);
+		List<StackingAndLoadingVehicles> stackingAndLoadingVehiclesList = stackingAndLoadingVehiclesMapper.selectList(queryWrapper);
+
+		if (oConvertUtils.listIsEmpty(stackingAndLoadingVehiclesList)){
+			log.info("{}{}", "该炉没有需要清空的堆垛信息:", heatNo);
+			return;
+		}
+
+		// 截取前amount条记录(如果数量不足则取全部)
+		List<StackingAndLoadingVehicles> recordsToUpdate = stackingAndLoadingVehiclesList.stream().limit(amount).collect(Collectors.toList());
+
+		List<String> ids = recordsToUpdate.stream().map(StackingAndLoadingVehicles::getId).collect(Collectors.toList());
+
+		// 创建更新包装器
+		LambdaUpdateWrapper<StackingAndLoadingVehicles> updateWrapper = new LambdaUpdateWrapper<>();
+		updateWrapper.in(StackingAndLoadingVehicles::getId, ids)
+				.set(StackingAndLoadingVehicles::getBilletNos, null)
+				.set(StackingAndLoadingVehicles::getSpec, null)
+				.set(StackingAndLoadingVehicles::getSteel, null)
+				.set(StackingAndLoadingVehicles::getSize, null)
+				.set(StackingAndLoadingVehicles::getShift, null)
+				.set(StackingAndLoadingVehicles::getHeatNo, null)
+				.set(StackingAndLoadingVehicles::getCreateDate, null)
+				.set(StackingAndLoadingVehicles::getShiftGroup, null)
+				.set(StackingAndLoadingVehicles::getUpdateTime, new Date());
+
+		// 执行批量更新
+		stackingAndLoadingVehiclesMapper.update(null, updateWrapper);
+	}
+
 	/***
 	 * 处理起垛
 	 * @param ccmNo
@@ -574,6 +615,45 @@ public class BilletOriginalProductRecordController extends JeecgController<Bille
 		return Result.OK("确认成功!");
 	}
 
+	@AutoLog(value = "确认凉钢坯打印单")
+	@ApiOperation(value="确认凉钢坯打印单", notes="确认凉钢坯打印单")
+	@RequestMapping(value = "/coldConfirmRecord", method = {RequestMethod.PUT})
+	public Result<String> coldConfirmRecord(@RequestBody BilletOriginalProductRecord billetOriginalProductRecord) {
+		BilletOriginalProductRecord bopr = billetOriginalProductRecordService.getById(billetOriginalProductRecord.getId());
+		if(bopr == null) {
+			return Result.error("未找到对应数据,编辑失败!");
+		}
+		LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+		applyColdConfirmInfo(billetOriginalProductRecord, sysUser);
+		billetOriginalProductRecordService.updateById(billetOriginalProductRecord);
+		// 原始记录属于步进冷床的属于凉钢坯,要进行下垛操作,无须更新钢坯原始记录中的步进冷床数量
+		// stackLength字段数据结构为:[{\"stackingCount\":24,\"stackingLength\":10680,\"stackingWeight\":58.056,\"stackingBhtcId\":\"9\"}]
+		String stackLengthJson = bopr.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");
+					String bhtcId = item.getString("stackingBhtcId");
+					if (stackingLength == null || stackingCount == null || bhtcId == null) {
+						log.info("步进冷床数据格式异常,跳过该记录: {}", item.toJSONString());
+						continue;
+					}
+					int demandStackingSum = stackingCount / 4;
+					if (demandStackingSum > 0){
+						// 下垛数量大于0时,执行指定数量的下垛操作
+						clearColdStackByHeatNo(bopr.getCcmNo(), bopr.getHeatNo(), String.valueOf(stackingLength), bhtcId, demandStackingSum);
+					}
+				}
+			}catch (Exception e){
+				log.info("确认凉钢坯打印单JSON解析失败,数据:{}", stackLengthJson, e);
+			}
+		}
+		return Result.OK("确认成功!");
+	}
+
 	/**
 	 *  推钢室快速创建装运单
 	 *
@@ -2466,6 +2546,14 @@ public class BilletOriginalProductRecordController extends JeecgController<Bille
 		}
 	}
 
+	private void applyColdConfirmInfo(BilletOriginalProductRecord record, LoginUser user) {
+		if (oConvertUtils.isNotEmpty(record.getConfirmTime())) {
+			record.setColdConfirmBy(user.getRealname());
+			record.setColdConfirmTime(new Date());
+			record.setColdRemark(record.getRemark());
+		}
+	}
+
 	// 提取的计算方法
 	private void updateStatistics(Map<String, BilletStatisticsDetail> statisticsMap,
 								  String size, int count, double sizeValue) {

+ 16 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetOriginalProductRecord/entity/BilletOriginalProductRecord.java

@@ -196,6 +196,22 @@ public class BilletOriginalProductRecord implements Serializable {
     private String nextHeatNo;
 
 
+    /**备注*/
+    @Excel(name = "备注", width = 15)
+    @ApiModelProperty(value = "备注")
+    private String coldRemark;
 
+    /**
+     * 确认人
+     */
+    @ApiModelProperty(value = "确认人")
+    private String coldConfirmBy;
+    /**
+     *  确认日期
+     */
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "确认日期")
+    private Date coldConfirmTime;
 
 }

+ 115 - 13
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/rollHeight/service/impl/RollHeightServiceImpl.java

@@ -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) {