Explorar el Código

Merge branch 'master' of http://123.57.213.14:3001/zgzt/dosb-java into master

lingpeng.li hace 1 mes
padre
commit
c9cfd50f4c

+ 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")

+ 155 - 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,124 @@ 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());
+					 billetHotsendChangeShift.setWasteBlankOutput(Math.max(billetHotsendChangeShift.getWasteBlankOutput() + totalWeightBigDecimal.doubleValue(), 0));
+					 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);
+	}
 }

+ 4 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetHotsendChangeShift/entity/BilletHotsendChangeShift.java

@@ -76,6 +76,10 @@ public class BilletHotsendChangeShift implements Serializable {
     @Excel(name = "当前废品支数", width = 15)
     @ApiModelProperty(value = "当前废品支数")
     private Integer wasteAmount;
+    /**叛废总重*/
+    @Excel(name = "叛废总重", width = 15)
+    @ApiModelProperty(value = "叛废总重")
+    private Double wasteBlankOutput;
     /**当前热送支数*/
     @Excel(name = "当前热送支数", width = 15)
     @ApiModelProperty(value = "当前热送支数")

+ 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

+ 280 - 1
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/storageBill/controller/StorageBillController.java

@@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 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.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -30,17 +32,27 @@ import org.jeecg.modules.billet.billetHotsend.entity.BilletHotsendDetailsVo;
 import org.jeecg.modules.billet.billetHotsend.service.IBilletHotsendBaseService;
 import org.jeecg.modules.billet.billetHotsendChangeShift.entity.BilletHotsendChangeShift;
 import org.jeecg.modules.billet.billetHotsendChangeShift.service.IBilletHotsendChangeShiftService;
+import org.jeecg.modules.billet.billetHotsendConfig.entity.BilletHotsendTypeConfig;
+import org.jeecg.modules.billet.billetHotsendConfig.service.IBilletHotsendTypeConfigService;
 import org.jeecg.modules.billet.operateLog.service.IOperateLogService;
 import org.jeecg.modules.billet.rollClubOne.entity.RollClubOneDetails;
 import org.jeecg.modules.billet.rollClubOne.service.IRollClubOneDetailsService;
+import org.jeecg.modules.billet.rollClubThree.entity.RollClubThree;
 import org.jeecg.modules.billet.rollClubThree.entity.RollClubThreeDetails;
 import org.jeecg.modules.billet.rollClubThree.service.IRollClubThreeDetailsService;
+import org.jeecg.modules.billet.rollClubThree.service.IRollClubThreeService;
+import org.jeecg.modules.billet.rollClubTwo.entity.RollClubTwo;
 import org.jeecg.modules.billet.rollClubTwo.entity.RollClubTwoDetails;
 import org.jeecg.modules.billet.rollClubTwo.service.IRollClubTwoDetailsService;
+import org.jeecg.modules.billet.rollClubTwo.service.IRollClubTwoService;
 import org.jeecg.modules.billet.rollHeight.entity.RollHeightDetails;
 import org.jeecg.modules.billet.rollHeight.service.IRollHeightDetailsService;
+import org.jeecg.modules.billet.rollOutShipp.entity.RollOutShipp;
 import org.jeecg.modules.billet.rollOutShipp.entity.RollOutShippDetails;
 import org.jeecg.modules.billet.rollOutShipp.service.IRollOutShippDetailsService;
+import org.jeecg.modules.billet.rollOutShipp.service.IRollOutShippService;
+import org.jeecg.modules.billet.stackingAndLoadingVehicles.entity.StackingAndLoadingVehicles;
+import org.jeecg.modules.billet.stackingAndLoadingVehicles.service.IStackingAndLoadingVehiclesService;
 import org.jeecg.modules.billet.storageBill.dto.HotChargingQueryDTO;
 import org.jeecg.modules.billet.storageBill.dto.StorageCenterQueryDTO;
 import org.jeecg.modules.billet.storageBill.entity.*;
@@ -52,6 +64,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.ModelAndView;
 
@@ -116,6 +129,20 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
 	@Autowired
 	private IBilletBasicInfoService billetBasicInfoService;
 
+	@Autowired
+	private IRollClubTwoService rollClubTwoService;
+
+	@Autowired
+	private IRollClubThreeService rollClubThreeService;
+
+	@Autowired
+	private IRollOutShippService rollOutShippService;
+
+	@Autowired
+	private IBilletHotsendTypeConfigService billetHotsendTypeConfigService;
+
+	@Autowired
+	private IStackingAndLoadingVehiclesService stackingAndLoadingVehiclesService;
 	/**
 	 * 分页列表查询
 	 *
@@ -500,7 +527,259 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
 		storageBillService.removeById(storageBill.getId());
 		return Result.OK("删除成功!");
 	}
-	
+
+	/**
+	 *   通过组批号移除
+	 *
+	 * @param storageBillVo
+	 * @return
+	 */
+	@AutoLog(value = "钢坯装运单-通过组批号移除")
+	@ApiOperation(value="钢坯装运单-通过组批号移除", notes="钢坯装运单-通过组批号移除")
+	@DeleteMapping(value = "/deleteByAssemblyNumber")
+	@Transactional(rollbackFor = Exception.class)
+	public Result<String> deleteByAssemblyNumber(@RequestBody StorageBillVo storageBillVo) {
+
+		// 根据id查询钢坯装运单信息
+		StorageBill storageBill = storageBillService.getById(storageBillVo.getId());
+		if (storageBill == null){
+			return Result.error("钢坯装运单信息为空,移除装运明细失败!");
+		}
+		//已发车的钢坯不能移除
+		if (oConvertUtils.isNotEmpty(storageBill.getOutTime())){
+			return Result.error("该钢坯装运单已发车,移除装运明细失败!");
+		}
+		if ("1024".equals(storageBill.getTypeConfigId())){
+			return Result.error("未选择目的地,无法移除装运明细!");
+		}
+
+		try {
+			List<String> billetNos = Arrays.asList(storageBillVo.getBillNos().split(","));
+			//查询并批量更新钢坯基础信息 belongTable
+			LambdaQueryWrapper<BilletBasicInfo> queryWrapperls = new LambdaQueryWrapper<BilletBasicInfo>()
+					.eq(BilletBasicInfo::getCcmNo, Integer.valueOf(storageBillVo.getCcmNo()))
+					.in(BilletBasicInfo::getBilletNo, billetNos);
+			List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(queryWrapperls);
+			if (oConvertUtils.listIsEmpty(billetBasicInfoList)){
+				return Result.error("钢坯基础信息不存在,移除装运明细失败!");
+			}
+
+			String finalHeatNo = billetBasicInfoList.get(0).getHeatNo();
+			Double sumBlankOutput;
+			int sumAmountTotal = billetBasicInfoList.size();
+			if ("棒二".equals(storageBillVo.getDestination())) {
+				List<RollClubTwoDetails> rollClubTwoDetailsList = rollClubTwoDetailsService.list(new LambdaQueryWrapper<RollClubTwoDetails>()
+						.eq(RollClubTwoDetails::getStorageBillId, storageBillVo.getId())
+						.eq(RollClubTwoDetails::getCcmNo, storageBillVo.getCcmNo())
+						.eq(RollClubTwoDetails::getAssemblyNumber, storageBillVo.getAssemblyNumber()));
+				sumBlankOutput = rollClubTwoDetailsList.stream().mapToDouble(RollClubTwoDetails::getBlankOutput).sum();
+				if (oConvertUtils.listIsNotEmpty(rollClubTwoDetailsList)){
+					rollClubTwoDetailsService.removeByIds(rollClubTwoDetailsList.stream().map(RollClubTwoDetails::getId).collect(Collectors.toList()));
+				}
+				LambdaQueryWrapper<RollClubTwo> queryWrapper = new LambdaQueryWrapper<RollClubTwo>()
+						.eq(RollClubTwo::getCcmNo, storageBillVo.getCcmNo())
+						.eq(RollClubTwo::getHeatNo, finalHeatNo)
+						.eq(RollClubTwo::getShiftGroup, storageBillVo.getShiftGroup())
+						.eq(RollClubTwo::getShift, storageBillVo.getShift())
+						.eq(RollClubTwo::getStorageBillId, storageBillVo.getId())
+						.last("limit 1");
+				RollClubTwo rollClubTwo = rollClubTwoService.getOne(queryWrapper);
+				if (oConvertUtils.isNotEmpty(rollClubTwo)){
+					rollClubTwo.setAmountTotal(Math.max(0, rollClubTwo.getAmountTotal() - sumAmountTotal));
+					rollClubTwo.setBlankOutput(Math.max(0, rollClubTwo.getBlankOutput() - sumBlankOutput));
+					rollClubTwoService.updateById(rollClubTwo);
+				}
+			}else if ("棒三".equals(storageBillVo.getDestination())) {
+				List<RollClubThreeDetails> rollClubThreeDetailsList = rollClubThreeDetailsService.list(new LambdaQueryWrapper<RollClubThreeDetails>()
+						.eq(RollClubThreeDetails::getStorageBillId, storageBillVo.getId())
+						.eq(RollClubThreeDetails::getCcmNo, storageBillVo.getCcmNo())
+						.eq(RollClubThreeDetails::getAssemblyNumber, storageBillVo.getAssemblyNumber()));
+				sumBlankOutput = rollClubThreeDetailsList.stream().mapToDouble(RollClubThreeDetails::getBlankOutput).sum();
+				if (oConvertUtils.listIsNotEmpty(rollClubThreeDetailsList)){
+					rollClubThreeDetailsService.removeByIds(rollClubThreeDetailsList.stream().map(RollClubThreeDetails::getId).collect(Collectors.toList()));
+				}
+				LambdaQueryWrapper<RollClubThree> queryWrapper = new LambdaQueryWrapper<RollClubThree>()
+						.eq(RollClubThree::getCcmNo, storageBillVo.getCcmNo())
+						.eq(RollClubThree::getHeatNo, finalHeatNo)
+						.eq(RollClubThree::getShiftGroup, storageBillVo.getShiftGroup())
+						.eq(RollClubThree::getShift, storageBillVo.getShift())
+						.eq(RollClubThree::getStorageBillId, storageBillVo.getId())
+						.last("limit 1");
+				RollClubThree rollClubThree = rollClubThreeService.getOne(queryWrapper);
+				if (oConvertUtils.isNotEmpty(rollClubThree)){
+					rollClubThree.setAmountTotal(Math.max(0, rollClubThree.getAmountTotal() - sumAmountTotal));
+					rollClubThree.setBlankOutput(Math.max(0, rollClubThree.getBlankOutput() - sumBlankOutput));
+					rollClubThreeService.updateById(rollClubThree);
+				}
+			}else if ("上若".equals(storageBillVo.getDestination())) {
+				List<RollOutShippDetails> rollOutShippDetailsList = rollOutShippDetailsService.list(new LambdaQueryWrapper<RollOutShippDetails>()
+						.eq(RollOutShippDetails::getStorageBillId, storageBillVo.getId())
+						.eq(RollOutShippDetails::getCcmNo, storageBillVo.getCcmNo())
+						.eq(RollOutShippDetails::getAssemblyNumber, storageBillVo.getAssemblyNumber()));
+				sumBlankOutput = rollOutShippDetailsList.stream().mapToDouble(RollOutShippDetails::getBlankOutput).sum();
+				if (oConvertUtils.listIsNotEmpty(rollOutShippDetailsList)){
+					rollOutShippDetailsService.removeByIds(rollOutShippDetailsList.stream().map(RollOutShippDetails::getId).collect(Collectors.toList()));
+				}
+				LambdaQueryWrapper<RollOutShipp> queryWrapper = new LambdaQueryWrapper<RollOutShipp>()
+						.eq(RollOutShipp::getCcmNo, storageBillVo.getCcmNo())
+						.eq(RollOutShipp::getHeatNo, finalHeatNo)
+						.eq(RollOutShipp::getShiftGroup, storageBillVo.getShiftGroup())
+						.eq(RollOutShipp::getShift, storageBillVo.getShift())
+						.eq(RollOutShipp::getStorageBillId, storageBillVo.getId())
+						.last("limit 1");
+				RollOutShipp rollOutShipp = rollOutShippService.getOne(queryWrapper);
+				if (oConvertUtils.isNotEmpty(rollOutShipp)){
+					rollOutShipp.setAmountTotal(Math.max(0, rollOutShipp.getAmountTotal() - sumAmountTotal));
+					rollOutShipp.setBlankOutput(Math.max(0, rollOutShipp.getBlankOutput() - sumBlankOutput));
+					rollOutShippService.updateById(rollOutShipp);
+				}
+			}
+			BilletHotsendTypeConfig billetHotsendTypeConfig = new BilletHotsendTypeConfig();
+			if (oConvertUtils.isNotEmpty(storageBillVo.getStackAddr())){
+				LambdaQueryWrapper<BilletHotsendTypeConfig> queryWrapper = new LambdaQueryWrapper<BilletHotsendTypeConfig>()
+						.eq(BilletHotsendTypeConfig::getTypeName, storageBillVo.getStackAddr())
+						.eq(BilletHotsendTypeConfig::getCastMachine, storageBillVo.getCcmNo());
+				billetHotsendTypeConfig = billetHotsendTypeConfigService.getOne(queryWrapper);
+				if (oConvertUtils.isEmpty(billetHotsendTypeConfig)){
+					TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+					return Result.error("钢坯配置信息为空,移除失败!");
+				}
+
+				List<StackingAndLoadingVehicles> stackingAndLoadingVehiclesList = new ArrayList<>();
+				StackingAndLoadingVehicles stackingAndLoadingVehiclesInfo = new StackingAndLoadingVehicles();
+				stackingAndLoadingVehiclesInfo.setCcmNo(storageBillVo.getCcmNo());
+				stackingAndLoadingVehiclesInfo.setTypeConfigId(billetHotsendTypeConfig.getId());
+				stackingAndLoadingVehiclesInfo.setStackAddr(billetHotsendTypeConfig.getTypeName());
+				stackingAndLoadingVehiclesInfo.setBilletNos(storageBillVo.getBillNos());
+				stackingAndLoadingVehiclesInfo.setLayer(storageBillVo.getStackStorey());
+				stackingAndLoadingVehiclesInfo.setAddress(storageBillVo.getStackNum());
+				stackingAndLoadingVehiclesList.add(stackingAndLoadingVehiclesInfo);
+
+				StackingAndLoadingVehicles stackingAndLoadingVehiclesPositionInfo = stackingAndLoadingVehiclesService.getOne(new LambdaQueryWrapper<StackingAndLoadingVehicles>()
+						.eq(StackingAndLoadingVehicles::getTypeConfigId, billetHotsendTypeConfig.getId())
+						.eq(StackingAndLoadingVehicles::getLayer, storageBillVo.getStackStorey())
+						.eq(StackingAndLoadingVehicles::getAddress, storageBillVo.getStackNum())
+						.eq(StackingAndLoadingVehicles::getCcmNo, storageBillVo.getCcmNo())
+				);
+				if (oConvertUtils.isNotEmpty(stackingAndLoadingVehiclesPositionInfo) && oConvertUtils.isNotEmpty(stackingAndLoadingVehiclesPositionInfo.getBilletNos())){
+					TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+					return Result.error("该层该位置已存在数据,装运明细移除失败!");
+				}
+
+				// 2 发车后,动态更新容器中的垛位信息 初始化
+				BilletHotsendTypeConfig finalBilletHotsendTypeConfig = billetHotsendTypeConfig;
+				stackingAndLoadingVehiclesList.forEach(x ->{
+					LambdaUpdateWrapper<StackingAndLoadingVehicles> queryWrapperSA = new LambdaUpdateWrapper<>();
+					queryWrapperSA.eq(StackingAndLoadingVehicles::getCcmNo, x.getCcmNo())
+							.eq(StackingAndLoadingVehicles::getLayer, x.getLayer())
+							.eq(StackingAndLoadingVehicles::getAddress, x.getAddress())
+							.eq(StackingAndLoadingVehicles::getTypeConfigId, finalBilletHotsendTypeConfig.getId());
+					StackingAndLoadingVehicles stackingAndLoadingVehicles = createInitializedVehicle();
+					BeanUtils.copyProperties(x, stackingAndLoadingVehicles);
+					BilletBasicInfo billetBasicInfo = billetBasicInfoList.stream().findFirst().orElse(null);
+					stackingAndLoadingVehicles.setShift(billetBasicInfo.getShift());
+					stackingAndLoadingVehicles.setShiftGroup(billetBasicInfo.getShiftGroup());
+					stackingAndLoadingVehicles.setCcmNo(billetBasicInfo.getCcmNo().toString());
+					stackingAndLoadingVehicles.setHeatNo(billetBasicInfo.getHeatNo());
+					stackingAndLoadingVehicles.setSize(billetBasicInfo.getLength().toString());
+					stackingAndLoadingVehicles.setSpec(billetBasicInfo.getSpec());
+					stackingAndLoadingVehicles.setSteel(billetBasicInfo.getGrade());
+					stackingAndLoadingVehicles.setCreateDate(new Date());
+					log.info("{}{}", "装运单移除钢坯,起跺容器中的信息:", JSON.toJSON(stackingAndLoadingVehicles));
+					stackingAndLoadingVehiclesService.update(stackingAndLoadingVehicles, queryWrapperSA);
+				});
+			}
+			LambdaQueryWrapper<BilletHotsend> queryWrapperBH = new LambdaQueryWrapper<BilletHotsend>()
+					.eq(BilletHotsend::getCcmNo, storageBillVo.getCcmNo())
+					.eq(BilletHotsend::getHeatNo, finalHeatNo)
+					.eq(BilletHotsend::getShiftGroup, storageBillVo.getShiftGroup())
+					.eq(BilletHotsend::getShift, storageBillVo.getShift())
+					.last("limit 1");
+			BilletHotsend billetHotsend = billetHotsendBaseService.getOne(queryWrapperBH);
+			if (oConvertUtils.isEmpty(billetHotsend)) {
+				TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+				return Result.error("热送传递单不存在,移除失败!");
+			}
+			updateClubNum(billetHotsend, storageBillVo.getDestination(), sumAmountTotal);
+			if (oConvertUtils.isNotEmpty(storageBillVo.getStackAddr())) {
+				billetHotsend.setStackNum(billetHotsend.getStackNum() + sumAmountTotal);
+			}
+			billetHotsendBaseService.updateById(billetHotsend);
+
+			for (BilletBasicInfo billetBasicInfo : billetBasicInfoList) {
+				LambdaUpdateWrapper<BilletBasicInfo> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
+				lambdaUpdateWrapper.eq(BilletBasicInfo::getId, billetBasicInfo.getId());
+				if (oConvertUtils.isNotEmpty(storageBillVo.getStackAddr())) {
+					lambdaUpdateWrapper.set(BilletBasicInfo::getBelongTable, "stacking_and_loading_vehicles");
+					lambdaUpdateWrapper.set(BilletBasicInfo::getBhtcId, billetHotsendTypeConfig.getId());
+				} else {
+					lambdaUpdateWrapper.set(BilletBasicInfo::getBelongTable, null);
+					lambdaUpdateWrapper.set(BilletBasicInfo::getBhtcId, null);
+				}
+				billetBasicInfoService.update(lambdaUpdateWrapper);
+			}
+
+			storageBill.setAmountTotal(Math.max(0, storageBill.getAmountTotal() - sumAmountTotal));
+			String assemblyNumber = storageBill.getAssemblyNumber();
+			String targetNumber = storageBillVo.getAssemblyNumber();
+			String newAssemblyNumber = Arrays.stream(assemblyNumber.split(","))
+					.filter(number -> !number.equals(targetNumber))
+					.collect(Collectors.joining(","));
+			LambdaUpdateWrapper<StorageBill> updateWrapper = new LambdaUpdateWrapper<>();
+			updateWrapper.eq(StorageBill::getId, storageBill.getId());
+			updateWrapper.set(StorageBill::getAmountTotal, storageBill.getAmountTotal());
+
+			if (oConvertUtils.isEmpty(newAssemblyNumber)) {
+				updateWrapper.set(StorageBill::getAssemblyNumber, null);
+			} else {
+				updateWrapper.set(StorageBill::getAssemblyNumber, newAssemblyNumber);
+			}
+			storageBillService.update(updateWrapper);
+		} catch (Exception e) {
+			log.error("装运明细移除发生异常:" + e.getMessage(), e);
+			return Result.error("装运明细移除异常!");
+		}
+		log.info("{}{}", ">>>>>>装运单移除成功的钢坯信息:", JSON.toJSON(storageBillVo));
+		return Result.OK("装运明细移除成功!");
+	}
+
+	/**
+	 * 炉次传递单棒二、棒三、上若总支数计算
+	 * @param billetHotsend
+	 * @param destination
+	 * @param sumAmountTotal
+	 */
+	private void updateClubNum(BilletHotsend billetHotsend, String destination, int sumAmountTotal) {
+		switch (destination) {
+			case "棒二":
+				billetHotsend.setRollclubtwoNum(Math.max(0, billetHotsend.getRollclubtwoNum() - sumAmountTotal));
+				break;
+			case "棒三":
+				billetHotsend.setRollclubthreeNum(Math.max(0, billetHotsend.getRollclubthreeNum() - sumAmountTotal));
+				break;
+			case "上若":
+				billetHotsend.setRolloutshippNum(Math.max(0, billetHotsend.getRolloutshippNum() - sumAmountTotal));
+				break;
+		}
+	}
+
+	/**
+	 * 初始化StackingAndLoadingVehicles对象
+	 * @return
+	 */
+	private StackingAndLoadingVehicles createInitializedVehicle() {
+		StackingAndLoadingVehicles vehicle = new StackingAndLoadingVehicles();
+		vehicle.setBilletNos(null);
+		vehicle.setSpec(null);
+		vehicle.setSteel(null);
+		vehicle.setSize(null);
+		vehicle.setShift(null);
+		vehicle.setHeatNo(null);
+		vehicle.setShiftGroup(null);
+		vehicle.setCreateDate(null);
+		return vehicle;
+	}
+
 	/**
 	 *  批量删除
 	 *

+ 19 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/storageBill/entity/StorageBillVo.java

@@ -0,0 +1,19 @@
+package org.jeecg.modules.billet.storageBill.entity;
+
+import lombok.Data;
+
+@Data
+public class StorageBillVo {
+    private String id;
+    private String ccmNo;
+    private String heatNo;
+    private String billNos;
+    private String shiftGroup;
+    private String shift;
+    private String assemblyNumber;
+    private String typeConfigId;
+    private String destination;
+    private String stackStorey;
+    private String stackNum;
+    private String stackAddr;
+}

+ 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());