Преглед изворни кода

钢坯实绩进行批量叛废

qiangxuan пре 1 месец
родитељ
комит
aabbf3a62a

+ 1 - 1
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/actualControl/billetActual/billetActual/controller/BilletBasicInfoController.java

@@ -75,7 +75,7 @@ public class BilletBasicInfoController extends JeecgController<BilletBasicInfo,
 		List<BilletBasicInfo> list = pageList.getRecords();
 		// 处理钢坯目的地信息
 		list.forEach(item ->{
-			if(oConvertUtils.isNotEmpty(item.getBhtcId())){ // 归属了目的地
+			if(oConvertUtils.isNotEmpty(item.getBhtcId()) && !"1025".equals(item.getBhtcId())){ // 归属了目的地
 				BilletHotsendTypeConfig billetHotsendTypeConfig = billetHotsendTypeConfigService.getById(item.getBhtcId());
 				item.setBhtcId(billetHotsendTypeConfig.getTypeName());
 			}

+ 5 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetHotsend/entity/BilletHotsend.java

@@ -130,6 +130,11 @@ public class BilletHotsend implements Serializable {
     @Excel(name = "判废支数", width = 15)
     @ApiModelProperty(value = "判废支数")
     private Integer wasteNum;
+    /**叛废总重*/
+    @Excel(name = "叛废总重", width = 15)
+    @ApiModelProperty(value = "叛废总重")
+    private Double wasteBlankOutput;
+
     /**C*/
     @Excel(name = "C", width = 15)
     @ApiModelProperty(value = "C")

+ 154 - 3
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetHotsendAbandons/controller/BilletHotsendAbandonsController.java

@@ -1,7 +1,11 @@
 package org.jeecg.modules.billet.billetHotsendAbandons.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -11,17 +15,33 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.actualControl.billetActual.billetActual.entity.BilletBasicInfo;
+import org.jeecg.modules.actualControl.billetActual.billetActual.service.IBilletBasicInfoService;
+import org.jeecg.modules.billet.billetHotsend.entity.BilletHotsend;
+import org.jeecg.modules.billet.billetHotsend.service.IBilletHotsendBaseService;
 import org.jeecg.modules.billet.billetHotsendAbandons.entity.BilletHotsendAbandons;
 import org.jeecg.modules.billet.billetHotsendAbandons.service.IBilletHotsendAbandonsService;
+import org.jeecg.modules.billet.billetHotsendChangeShift.entity.BilletHotsendChangeShift;
+import org.jeecg.modules.billet.billetHotsendChangeShift.service.IBilletHotsendChangeShiftService;
+import org.jeecg.modules.billet.stackingAndLoadingVehicles.entity.StackingAndLoadingVehicles;
+import org.jeecg.modules.billet.stackingAndLoadingVehicles.service.IStackingAndLoadingVehiclesService;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.ModelAndView;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.util.Arrays;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.*;
+import java.util.stream.Collectors;
 
- /**
+/**
  * @Description: 钢坯热送单炉支数传递单判废记录
  * @Author: jeecg-boot
  * @Date:   2024-11-19
@@ -32,9 +52,21 @@ import java.util.Arrays;
 @RequestMapping("/billetHotsend/billetHotsendAbandons")
 @Slf4j
 public class BilletHotsendAbandonsController extends JeecgController<BilletHotsendAbandons, IBilletHotsendAbandonsService> {
+
 	@Autowired
 	private IBilletHotsendAbandonsService billetHotsendAbandonsService;
-	
+
+	@Autowired
+	private IBilletHotsendBaseService billetHotsendBaseService;
+
+	@Autowired
+	private IBilletBasicInfoService billetBasicInfoService;
+
+	@Autowired
+	private IStackingAndLoadingVehiclesService stackingAndLoadingVehiclesService;
+
+	@Autowired
+	private IBilletHotsendChangeShiftService billetHotsendChangeShiftService;
 	/**
 	 * 分页列表查询
 	 *
@@ -159,4 +191,123 @@ public class BilletHotsendAbandonsController extends JeecgController<BilletHotse
         return super.importExcel(request, response, BilletHotsendAbandons.class);
     }
 
+	 @AutoLog(value = "钢坯实绩判废-批量判废")
+	 @ApiOperation(value="钢坯实绩判废-批量判废", notes="钢坯实绩判废-批量判废")
+	 @DeleteMapping(value = "/abandonsBatch")
+	 @Transactional(rollbackFor = Exception.class)
+	 public Result<String> abandonsBatchHandle(@RequestParam(name="ids",required=true) String ids) {
+
+		 try {
+			 //根据逗号拼接的ids、BelongTable等于stacking_and_loading_vehicles或者为null 的所有钢坯基础信息
+			 LambdaQueryWrapper<BilletBasicInfo> queryWrapper = new LambdaQueryWrapper<>();
+			 queryWrapper.in(BilletBasicInfo::getId, Arrays.asList(ids.split(",")));
+			 List<BilletBasicInfo> billetBasicInfos = billetBasicInfoService.list(queryWrapper);
+			 if (oConvertUtils.listIsEmpty(billetBasicInfos)){
+				 return Result.error("未找到对应数据");
+			 }
+
+			 // 更新钢坯实绩为叛废记录,belongTable = "billet_hotsend_abandons", bhtcId = "1025"
+			 List<BilletBasicInfo> billetBasicInfoLists = new ArrayList<>();
+			 for (BilletBasicInfo billetBasicInfo : billetBasicInfos) {
+				 billetBasicInfo.setBelongTable("billet_hotsend_abandons");
+				 billetBasicInfo.setBhtcId("1025");
+				 billetBasicInfoLists.add(billetBasicInfo);
+			 }
+			 billetBasicInfoService.updateBatchById(billetBasicInfoLists);
+
+			 // 对 billetBasicInfos 根据炉号、班组、班别进行分组,
+			 Map<String, List<BilletBasicInfo>> groupedMap = billetBasicInfos.stream()
+					 .collect(Collectors.groupingBy(info -> info.getHeatNo() + "-" + info.getShiftGroup() + "-" + info.getShift()));
+
+			 for (Map.Entry<String, List<BilletBasicInfo>> entry : groupedMap.entrySet()) {
+				 List<BilletBasicInfo> group = entry.getValue();
+				 if (oConvertUtils.listIsNotEmpty(group)) {
+
+					 // 计算 group 中 billetWeight 总重量,保留 4 位小数
+					 double totalWeight = group.stream()
+							 .mapToDouble(BilletBasicInfo::getBilletWeight)
+							 .sum();
+					 BigDecimal totalWeightBigDecimal = new BigDecimal(totalWeight).setScale(4, RoundingMode.HALF_UP);
+
+					 BilletBasicInfo firstInfo = group.get(0);
+					 String heatNo = firstInfo.getHeatNo();
+					 String shiftGroup = firstInfo.getShiftGroup();
+					 String shift = firstInfo.getShift();
+					 String ccmNo = String.valueOf(firstInfo.getCcmNo());
+					 // 根据炉号、班组、班别、铸机号 查询该钢坯热送传递单,返回一个对象
+					 LambdaQueryWrapper<BilletHotsend> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+					 lambdaQueryWrapper.eq(BilletHotsend::getHeatNo, heatNo)
+							 .eq(BilletHotsend::getShiftGroup, shiftGroup)
+							 .eq(BilletHotsend::getShift, shift)
+							 .eq(BilletHotsend::getCcmNo, ccmNo);
+					 BilletHotsend billetHotsend = billetHotsendBaseService.getOne(lambdaQueryWrapper, false);
+					 if (billetHotsend == null){
+						 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+						 return Result.error("钢坯炉次传递单查询失败,叛废失败!");
+					 }
+					 // 更新BilletHotsend中的wasteNum字段,并更新BilletHotsend对象
+					 billetHotsend.setWasteNum(billetHotsend.getWasteNum() + group.size());
+					 billetHotsend.setWasteBlankOutput(billetHotsend.getWasteBlankOutput() + totalWeightBigDecimal.doubleValue());
+					 billetHotsendBaseService.updateById(billetHotsend);
+
+					 // 更新交班记录
+					 LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapperBilletHotsendChangeShift = new LambdaQueryWrapper<BilletHotsendChangeShift>()
+							 .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(queryWrapperBilletHotsendChangeShift, false);
+					 if (billetHotsendChangeShift == null){
+						 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+						 return Result.error("交班记录查询失败,叛废失败!");
+					 }
+					 // 减掉总重量
+					 billetHotsendChangeShift.setShiftProduct(Math.max(billetHotsendChangeShift.getShiftProduct() - totalWeightBigDecimal.doubleValue(), 0));
+					 billetHotsendChangeShift.setShiftSum(Math.max(billetHotsendChangeShift.getShiftSum() - group.size(), 0));
+					 billetHotsendChangeShift.setWasteAmount(billetHotsendChangeShift.getWasteAmount() + group.size());
+					 billetHotsendChangeShiftService.updateById(billetHotsendChangeShift);
+				 }
+			 }
+
+			 //根据billetBasicInfos遍历 保存叛废记录
+			 List<BilletHotsendAbandons> billetHotsendAbandonsList = new ArrayList<>();
+			 for (BilletBasicInfo billetBasicInfo : billetBasicInfos) {
+				 BilletHotsendAbandons billetHotsendAbandons = new BilletHotsendAbandons();
+				 BeanUtils.copyProperties(billetBasicInfo, billetHotsendAbandons);
+				 billetHotsendAbandons.setId(String.valueOf(IdWorker.getId()));
+				 billetHotsendAbandons.setCcmNo(String.valueOf(billetBasicInfo.getCcmNo()));
+				 billetHotsendAbandons.setSize(String.valueOf(billetBasicInfo.getLength()));
+				 billetHotsendAbandonsList.add(billetHotsendAbandons);
+			 }
+			 billetHotsendAbandonsService.saveBatch(billetHotsendAbandonsList);
+		 } catch (Exception e) {
+			 log.warn("{}{}", "批量判废异常:", e.getMessage());
+		 }
+		 return Result.OK("批量判废成功!");
+	 }
+
+	/**
+	 *  初始化堆垛公共容器
+	 * @param stackingAndLoadingVehiclesList
+	 */
+	private void batchUpdateStackingAndLoadingVehicles(List<StackingAndLoadingVehicles> stackingAndLoadingVehiclesList) {
+
+		List<String> ids = stackingAndLoadingVehiclesList.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());
+		// 执行批量更新
+		stackingAndLoadingVehiclesService.update(null, updateWrapper);
+	}
 }

+ 11 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/stackingAndLoadingVehicles/mapper/StackingAndLoadingVehiclesMapper.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.billet.stackingAndLoadingVehicles.mapper;
 import java.util.List;
 
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 import org.jeecg.modules.billet.stackingAndLoadingVehicles.entity.StackingAndLoadingVehicles;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
@@ -14,4 +15,14 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface StackingAndLoadingVehiclesMapper extends BaseMapper<StackingAndLoadingVehicles> {
 
+    @Select({
+            "<script>",
+            "SELECT * FROM stacking_and_loading_vehicles",
+            "WHERE",
+            "<foreach item='num' collection='billetNos.split(\",\")' separator=' AND '>",
+            "FIND_IN_SET(#{num}, billet_nos) > 0",
+            "</foreach>",
+            "</script>"
+    })
+    List<StackingAndLoadingVehicles> selectByBilletNos(@Param("billetNos") String billetNos);
 }

+ 2 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/stackingAndLoadingVehicles/service/IStackingAndLoadingVehiclesService.java

@@ -27,4 +27,6 @@ public interface IStackingAndLoadingVehiclesService extends IService<StackingAnd
     String judgeDiscardHandle(LoadingParams loadingParams);
 
     List<ClipLayerVo> clipNumAndLayerNum();
+
+    List<StackingAndLoadingVehicles> selectByBilletNos(String billetNos);
 }

+ 90 - 50
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/stackingAndLoadingVehicles/service/impl/StackingAndLoadingVehiclesServiceImpl.java

@@ -53,10 +53,12 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.NoTransactionException;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -894,70 +896,103 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
     }
 
     @Override
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     public String judgeDiscardHandle(LoadingParams loadingParams) {
         List<StackingAndLoadingVehicles> stackingAndLoadingVehiclesList = loadingParams.getStackingAndLoadingVehiclesList();
         if (oConvertUtils.listIsEmpty(stackingAndLoadingVehiclesList)) {
             return "钢坯叛废记录不存在!";
         }
 
-        // 批量更新 StackingAndLoadingVehicles
-        batchUpdateStackingAndLoadingVehicles(stackingAndLoadingVehiclesList);
+        try {
+            // 批量更新 StackingAndLoadingVehicles
+            batchUpdateStackingAndLoadingVehicles(stackingAndLoadingVehiclesList);
 
-        // 生成叛废记录
-        List<BilletHotsendAbandons> billetHotsendAbandonsList = new ArrayList<>();
-        // 2 发车后,动态更新容器中的垛位信息 初始化
-        stackingAndLoadingVehiclesList.forEach(x -> {
-            // 拆分四个钢坯集,组成叛废记录
-            List<String> sizeList = Arrays.asList(x.getSize().split(","));
-            List<String> billetNosList = Arrays.asList(x.getBilletNos().split(","));
-            billetNosList.forEach(y -> {
-                // 每次循环创建一个全新的BilletHotsendAbandons对象
-                BilletHotsendAbandons billetHotsendAbandons = new BilletHotsendAbandons();
-                BeanUtils.copyProperties(x, billetHotsendAbandons);
-                billetHotsendAbandons.setId(String.valueOf(IdWorker.getId()));
-                billetHotsendAbandons.setBilletNo(y);
-                billetHotsendAbandons.setStackStorey(x.getLayer());
-                billetHotsendAbandons.setStackNum(x.getAddress());
-                billetHotsendAbandons.setCreateTime(new Date());
-                if (oConvertUtils.listIsNotEmpty(sizeList)) {
-                    billetHotsendAbandons.setSize(sizeList.get(0));// 一夹4组,定尺是一致的
+            // 2025/04/29  垛位叛废更新钢坯基础实绩
+            List<BilletBasicInfo> updateBilletBasicInfoList = new ArrayList<>();
+            // 使用 Stream API 提取所有坯号
+            List<String> allBilletNos = stackingAndLoadingVehiclesList.stream()
+                    .map(StackingAndLoadingVehicles::getBilletNos) // 提取每个对象的坯号字符串
+                    .flatMap(billetNosStr -> Arrays.stream(billetNosStr.split(","))) // 将逗号分隔的字符串拆分为单个坯号并合并流
+                    .collect(Collectors.toList()); // 收集到一个新的列表中
+            List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(new LambdaQueryWrapper<BilletBasicInfo>().in(BilletBasicInfo::getBilletNo, allBilletNos));
+            if (oConvertUtils.listIsEmpty(billetBasicInfoList)){
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return "钢坯实绩查询为空,垛位叛废失败!";
+            }
+            for (BilletBasicInfo billetBasicInfo : billetBasicInfoList) {
+                billetBasicInfo.setBelongTable("billet_hotsend_abandons");
+                billetBasicInfo.setBhtcId("1025");
+                updateBilletBasicInfoList.add(billetBasicInfo);
+            }
+            billetBasicInfoService.updateBatchById(updateBilletBasicInfoList);
+            // 计算 group 中 billetWeight 总重量,保留 4 位小数
+            double totalWeight = billetBasicInfoList.stream()
+                    .mapToDouble(BilletBasicInfo::getBilletWeight)
+                    .sum();
+            BigDecimal totalWeightBigDecimal = new BigDecimal(totalWeight).setScale(4, RoundingMode.HALF_UP);
+            // 生成叛废记录
+            List<BilletHotsendAbandons> billetHotsendAbandonsList = new ArrayList<>();
+
+            // 2 发车后,动态更新容器中的垛位信息 初始化
+            stackingAndLoadingVehiclesList.forEach(x -> {
+                // 拆分四个钢坯集,组成叛废记录
+                List<String> sizeList = Arrays.asList(x.getSize().split(","));
+                List<String> billetNosList = Arrays.asList(x.getBilletNos().split(","));
+                billetNosList.forEach(y -> {
+                    // 每次循环创建一个全新的BilletHotsendAbandons对象
+                    BilletHotsendAbandons billetHotsendAbandons = new BilletHotsendAbandons();
+                    BeanUtils.copyProperties(x, billetHotsendAbandons);
+                    billetHotsendAbandons.setId(String.valueOf(IdWorker.getId()));
+                    billetHotsendAbandons.setBilletNo(y);
+                    billetHotsendAbandons.setStackStorey(x.getLayer());
+                    billetHotsendAbandons.setStackNum(x.getAddress());
+                    billetHotsendAbandons.setCreateTime(new Date());
+                    if (oConvertUtils.listIsNotEmpty(sizeList)) {
+                        billetHotsendAbandons.setSize(sizeList.get(0));// 一夹4组,定尺是一致的
+                    }
+                    billetHotsendAbandonsList.add(billetHotsendAbandons);
+                });
+                // 先根据垛位容器中的铸机号和炉号 查询钢坯热送基础信息
+                LambdaQueryWrapper<BilletHotsend> queryWrapperBH = new LambdaQueryWrapper<>();
+                queryWrapperBH.eq(BilletHotsend::getCcmNo, x.getCcmNo())
+                        .eq(BilletHotsend::getHeatNo, x.getHeatNo())
+                        .eq(BilletHotsend::getShift, x.getShift())
+                        .eq(BilletHotsend::getShiftGroup, x.getShiftGroup());
+                BilletHotsend idExistBh = billetHotsendBaseService.getOne(queryWrapperBH);
+                if (oConvertUtils.isEmpty(idExistBh)) {
+                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                    return;
                 }
-                billetHotsendAbandonsList.add(billetHotsendAbandons);
-            });
-            // 先根据垛位容器中的铸机号和炉号 查询钢坯热送基础信息
-            LambdaQueryWrapper<BilletHotsend> queryWrapperBH = new LambdaQueryWrapper<>();
-            queryWrapperBH.eq(BilletHotsend::getCcmNo, x.getCcmNo())
-                    .eq(BilletHotsend::getHeatNo, x.getHeatNo())
-                    .eq(BilletHotsend::getShift, x.getShift())
-                    .eq(BilletHotsend::getShiftGroup, x.getShiftGroup());
-            BilletHotsend idExistBh = billetHotsendBaseService.getOne(queryWrapperBH);
-            if (oConvertUtils.isNotEmpty(idExistBh)) {
-                log.info("{}{}", ">>>>>更新钢坯热送基础信息叛废支数:", JSON.toJSON(idExistBh));
+                log.info("{}{}", ">>>>>更新钢坯热送基础信息:", JSON.toJSON(idExistBh));
                 idExistBh.setWasteNum(oConvertUtils.isEmpty(idExistBh.getWasteNum()) ? 4 : idExistBh.getWasteNum() + 4);
-                idExistBh.setStackNum(idExistBh.getStackNum() - 4);
-                idExistBh.setUpdateTime(new Date());
+                idExistBh.setStackNum(Math.max(idExistBh.getStackNum() - 4, 0));
+                idExistBh.setWasteBlankOutput(idExistBh.getWasteBlankOutput() + totalWeightBigDecimal.doubleValue());
                 billetHotsendBaseService.updateById(idExistBh);
+            });
+            billetHotsendAbandonsService.saveBatch(billetHotsendAbandonsList);
+            log.info("{}{}", "保存钢坯垛位叛废记录总数:", billetHotsendAbandonsList.size());
+            // 根据交班表的当前判废总数
+            String shiftGroup = stackingAndLoadingVehiclesList.get(0).getShiftGroup();
+            String shift = stackingAndLoadingVehiclesList.get(0).getShift();
+            LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapperCS = new LambdaQueryWrapper<>();
+            queryWrapperCS.eq(BilletHotsendChangeShift::getCcmNo, loadingParams.getBilletHotsend().getCcmNo())
+                    .eq(BilletHotsendChangeShift::getShift, shift)
+                    .eq(BilletHotsendChangeShift::getShiftGroup, shiftGroup)
+                    .orderByDesc(BilletHotsendChangeShift::getCreateTime).last("limit 1"); // 按照创建时间倒序排列
+            BilletHotsendChangeShift billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapperCS);
+            log.info("{}{}", ">>>>>判废交班记录信息:", JSON.toJSON(billetHotsendChangeShift));
+            if (oConvertUtils.isEmpty(billetHotsendChangeShift)) {
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return "交班记录查询为空,垛位叛废失败!";
             }
-        });
-        billetHotsendAbandonsService.saveBatch(billetHotsendAbandonsList);
-        log.info("{}{}", "保存钢坯叛废记录总数:", billetHotsendAbandonsList.size());
-        // 根据交班表的当前判废总数
-        LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapperCS = new LambdaQueryWrapper<>();
-        queryWrapperCS.eq(BilletHotsendChangeShift::getCcmNo, loadingParams.getBilletHotsend().getCcmNo())
-                .eq(BilletHotsendChangeShift::getShift, loadingParams.getBilletHotsend().getShift())
-                .eq(BilletHotsendChangeShift::getShiftGroup, loadingParams.getBilletHotsend().getShiftGroup())
-                .orderByDesc(BilletHotsendChangeShift::getCreateTime).last("limit 1"); // 按照创建时间倒序排列
-        BilletHotsendChangeShift billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapperCS);
-        log.info("{}{}", ">>>>>判废交班记录信息:", JSON.toJSON(billetHotsendChangeShift));
-        if (oConvertUtils.isNotEmpty(billetHotsendChangeShift)) {
             billetHotsendChangeShift.setWasteAmount(oConvertUtils.isEmpty(billetHotsendChangeShift.getWasteAmount()) ? stackingAndLoadingVehiclesList.size() : billetHotsendChangeShift.getWasteAmount() + stackingAndLoadingVehiclesList.size() * 4);
-            billetHotsendChangeShift.setUpdateTime(new Date());
-            log.info("{}{}", ">>>>>更新交班记录判废支数:", billetHotsendChangeShift.getWasteAmount());
+            billetHotsendChangeShift.setShiftSum(Math.max(billetHotsendChangeShift.getShiftSum() - stackingAndLoadingVehiclesList.size() * 4, 0));
+            billetHotsendChangeShift.setShiftProduct(Math.max(billetHotsendChangeShift.getShiftProduct() - totalWeightBigDecimal.doubleValue(), 0));
             billetHotsendChangeShiftService.updateById(billetHotsendChangeShift);
+        } catch (Exception e) {
+            log.warn("{}{}", ">>>>>垛位叛废异常:", e.getMessage());
         }
-
-        return "钢坯叛废成功!";
+        return "垛位叛废成功!";
     }
 
     @Override
@@ -1004,6 +1039,11 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
         return result;
     }
 
+    @Override
+    public List<StackingAndLoadingVehicles> selectByBilletNos(String billetNos) {
+        return stackingAndLoadingVehiclesMapper.selectByBilletNos(billetNos);
+    }
+
     /**
      *  初始化堆垛公共容器
      * @param stackingAndLoadingVehiclesList

+ 2 - 1
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/storageBill/service/impl/StorageBillServiceImpl.java

@@ -2720,7 +2720,8 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
         LambdaQueryWrapper<BilletBasicInfo> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(BilletBasicInfo::getCcmNo, ccmNo)
                 .eq(BilletBasicInfo::getShift, shift)
-                .eq(BilletBasicInfo::getShiftGroup, shiftGroup);
+                .eq(BilletBasicInfo::getShiftGroup, shiftGroup)
+                .ne(BilletBasicInfo::getBhtcId, "1025");
         if (oConvertUtils.isEmpty(changeShiftId)) {
             // 当 changeShiftId 为空时,时间范围从 createTime 到当前时间
             queryWrapper.between(BilletBasicInfo::getCreateTime, billetHotsendChangeShift.getCreateTime(), new Date());