|
@@ -692,82 +692,83 @@ public class BilletOriginalProductRecordController extends JeecgController<Bille
|
|
|
.filter(obj -> parseLength.apply(obj.get("stackingLength")) == targetSize)
|
|
|
.findFirst()
|
|
|
.orElse(null);
|
|
|
- if (item != null){
|
|
|
- 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());
|
|
|
- return Result.error("凉坯确认数据格式异常,请检查数据!");
|
|
|
- }
|
|
|
- int appointColdBilletCount = billetOriginalProductRecordVo.getColdAmount();
|
|
|
- int finalStackingCount = stackingCount - appointColdBilletCount;
|
|
|
- if (finalStackingCount < 0){
|
|
|
- log.info("确认凉坯的数量不能超过总数: {}", item.toJSONString());
|
|
|
- return Result.error("凉坯确认异常,确认凉坯的数量不能超过总数!");
|
|
|
- }
|
|
|
- if (finalStackingCount == 0){
|
|
|
- applyColdConfirmInfo(bopr, sysUser);
|
|
|
- }else {
|
|
|
- // 拆分指定数量的凉坯单
|
|
|
- String appointColdBilletJsonArray = handleAppointColdBillet(bopr, appointColdBilletCount, targetSize, sysUser.getRealname());
|
|
|
- // 更新原堆垛信息,减去已拆分的数量和重量
|
|
|
- if (stackArray != null && !stackArray.isEmpty()) {
|
|
|
- try {
|
|
|
- // 查找需要更新的堆垛记录
|
|
|
- for (Object obj : stackArray) {
|
|
|
- JSONObject stackingItem = (JSONObject) obj;
|
|
|
- int currentLength = parseLength.apply(stackingItem.get("stackingLength"));
|
|
|
- if (currentLength == targetSize) {
|
|
|
- // 减去已拆分的数量
|
|
|
- int originalCount = stackingItem.getInteger("stackingCount");
|
|
|
- int newCount = originalCount - appointColdBilletCount;
|
|
|
- // 更新堆垛数量
|
|
|
- stackingItem.put("stackingCount", newCount);
|
|
|
- // 更新重量
|
|
|
- BigDecimal sizeDecimal = new BigDecimal(currentLength);
|
|
|
- BigDecimal weight = calculateWeight(sizeDecimal, newCount);
|
|
|
- stackingItem.put("stackingWeight", weight);
|
|
|
- break; // 找到后跳出循环
|
|
|
- }
|
|
|
+ if (item == null){
|
|
|
+ return Result.error("凉坯确认定尺不匹配,确认失败!");
|
|
|
+ }
|
|
|
+ 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());
|
|
|
+ return Result.error("凉坯确认数据格式异常,请检查数据!");
|
|
|
+ }
|
|
|
+ int appointColdBilletCount = billetOriginalProductRecordVo.getColdAmount();
|
|
|
+ int finalStackingCount = stackingCount - appointColdBilletCount;
|
|
|
+ if (finalStackingCount < 0){
|
|
|
+ log.info("确认凉坯的数量不能超过总数: {}", item.toJSONString());
|
|
|
+ return Result.error("凉坯确认异常,确认凉坯的数量不能超过总数!");
|
|
|
+ }
|
|
|
+ if (finalStackingCount == 0){
|
|
|
+ applyColdConfirmInfo(bopr, sysUser);
|
|
|
+ }else {
|
|
|
+ // 拆分指定数量的凉坯单
|
|
|
+ String appointColdBilletJsonArray = handleAppointColdBillet(bopr, appointColdBilletCount, targetSize, sysUser.getRealname());
|
|
|
+ // 更新原堆垛信息,减去已拆分的数量和重量
|
|
|
+ if (stackArray != null && !stackArray.isEmpty()) {
|
|
|
+ try {
|
|
|
+ // 查找需要更新的堆垛记录
|
|
|
+ for (Object obj : stackArray) {
|
|
|
+ JSONObject stackingItem = (JSONObject) obj;
|
|
|
+ int currentLength = parseLength.apply(stackingItem.get("stackingLength"));
|
|
|
+ if (currentLength == targetSize) {
|
|
|
+ // 减去已拆分的数量
|
|
|
+ int originalCount = stackingItem.getInteger("stackingCount");
|
|
|
+ int newCount = originalCount - appointColdBilletCount;
|
|
|
+ // 更新堆垛数量
|
|
|
+ stackingItem.put("stackingCount", newCount);
|
|
|
+ // 更新重量
|
|
|
+ BigDecimal sizeDecimal = new BigDecimal(currentLength);
|
|
|
+ BigDecimal weight = calculateWeight(sizeDecimal, newCount);
|
|
|
+ stackingItem.put("stackingWeight", weight);
|
|
|
+ break; // 找到后跳出循环
|
|
|
}
|
|
|
- // 更新bopr中的堆垛信息
|
|
|
- bopr.setStackLength(stackArray.toJSONString());
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("凉坯拆分发生异常", e);
|
|
|
- }
|
|
|
- }
|
|
|
- // 判断一下bopr.getColdBilletInfo是否为空,不为空的话,把拆分后的数据保存在bopr.getColdBilletInfo()中
|
|
|
- if (oConvertUtils.isNotEmpty(bopr.getColdBilletInfo())) {
|
|
|
- try {
|
|
|
- // 使用FastJSON解析现有数据和新数据
|
|
|
- JSONArray existingArray = JSON.parseArray(bopr.getColdBilletInfo());
|
|
|
- JSONArray newArray = JSON.parseArray(appointColdBilletJsonArray);
|
|
|
- // 将新数组中的元素添加到现有数组
|
|
|
- existingArray.addAll(newArray);
|
|
|
- // 更新bopr中的冷坯信息
|
|
|
- bopr.setColdBilletInfo(existingArray.toJSONString());
|
|
|
- } catch (Exception e) {
|
|
|
- // 处理JSON解析异常
|
|
|
- log.error("合并冷坯信息时发生JSON解析错误", e);
|
|
|
}
|
|
|
- } else {
|
|
|
- // 如果原数组为空,直接设置新数组
|
|
|
- bopr.setColdBilletInfo(appointColdBilletJsonArray);
|
|
|
+ // 更新bopr中的堆垛信息
|
|
|
+ bopr.setStackLength(stackArray.toJSONString());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("凉坯拆分发生异常", e);
|
|
|
}
|
|
|
}
|
|
|
- billetOriginalProductRecordService.updateById(bopr);
|
|
|
- int demandStackingSum = appointColdBilletCount / 4;
|
|
|
- // 确保下垛数量大于0并且是步进冷床类型,才进行容器释放(下垛)
|
|
|
- if (demandStackingSum > 0 && "9".equals(bhtcId)){
|
|
|
- // 下垛数量大于0时,执行指定数量的下垛操作
|
|
|
- clearColdStackByHeatNo(bopr.getCcmNo(), bopr.getHeatNo(), String.valueOf(stackingLength), bhtcId, demandStackingSum);
|
|
|
- String lengthKey = stackingLength.toString();
|
|
|
- lengthCountMap.merge(lengthKey, stackingCount, Integer::sum);
|
|
|
+ // 判断一下bopr.getColdBilletInfo是否为空,不为空的话,把拆分后的数据保存在bopr.getColdBilletInfo()中
|
|
|
+ if (oConvertUtils.isNotEmpty(bopr.getColdBilletInfo())) {
|
|
|
+ try {
|
|
|
+ // 使用FastJSON解析现有数据和新数据
|
|
|
+ JSONArray existingArray = JSON.parseArray(bopr.getColdBilletInfo());
|
|
|
+ JSONArray newArray = JSON.parseArray(appointColdBilletJsonArray);
|
|
|
+ // 将新数组中的元素添加到现有数组
|
|
|
+ existingArray.addAll(newArray);
|
|
|
+ // 更新bopr中的冷坯信息
|
|
|
+ bopr.setColdBilletInfo(existingArray.toJSONString());
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 处理JSON解析异常
|
|
|
+ log.error("合并冷坯信息时发生JSON解析错误", e);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 如果原数组为空,直接设置新数组
|
|
|
+ bopr.setColdBilletInfo(appointColdBilletJsonArray);
|
|
|
}
|
|
|
}
|
|
|
+ billetOriginalProductRecordService.updateById(bopr);
|
|
|
+ int demandStackingSum = appointColdBilletCount / 4;
|
|
|
+ // 确保下垛数量大于0并且是步进冷床类型,才进行容器释放(下垛)
|
|
|
+ if (demandStackingSum > 0 && "9".equals(bhtcId)){
|
|
|
+ // 下垛数量大于0时,执行指定数量的下垛操作
|
|
|
+ clearColdStackByHeatNo(bopr.getCcmNo(), bopr.getHeatNo(), String.valueOf(stackingLength), bhtcId, demandStackingSum);
|
|
|
+ String lengthKey = stackingLength.toString();
|
|
|
+ lengthCountMap.merge(lengthKey, stackingCount, Integer::sum);
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
- log.info("确认凉钢坯打印单JSON解析失败,数据:{}", stackLengthJson, e);
|
|
|
+ log.info("确认凉坯打印单异常:{}", stackLengthJson, e);
|
|
|
}
|
|
|
}
|
|
|
// 遍历每条记录构建 BilletUseInfoAddDTO 并保存
|