소스 검색

储运记录重量支数维护

qiangxuan 2 달 전
부모
커밋
e8ea64b27e

+ 31 - 1
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetHotsend/service/impl/BilletHotsendBaseServiceImpl.java

@@ -61,6 +61,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.stream.Collectors;
@@ -350,7 +351,36 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 		BeanUtils.copyProperties(storageBillInfo, storageCarLog);
 		storageCarLog.setDestination(storageBillInfo.getDestination());// 目的地
 		storageCarLog.setCarNm(storageBillInfo.getLicensePlate());// 车牌号
-//			storageCarLog.setFixedWeight();// 定重
+		if("棒二".equals(storageBillInfo.getDestination())){
+			// 根据装运单ID,查询棒二明细表
+			LambdaQueryWrapper<RollClubTwoDetails> queryWrapperRC = new LambdaQueryWrapper();
+			queryWrapperRC.eq(RollClubTwoDetails::getStorageBillId, storageBillInfo.getId());
+			List<RollClubTwoDetails> rollClubTwoDetailsList = rollClubTwoDetailsService.list(queryWrapperRC);
+			if (oConvertUtils.listIsNotEmpty(rollClubTwoDetailsList)){
+				double totalBlankOutputs = rollClubTwoDetailsList.stream().mapToDouble(RollClubTwoDetails::getBlankOutput).sum();
+				BigDecimal bd = BigDecimal.valueOf(totalBlankOutputs).setScale(4, BigDecimal.ROUND_HALF_UP);
+				storageCarLog.setFixedWeight(bd.doubleValue());
+			}
+		}else if ("棒三".equals(storageBillInfo.getDestination())) {
+			// 根据装运单ID,查询棒二明细表
+			LambdaQueryWrapper<RollClubThreeDetails> queryWrapperRT = new LambdaQueryWrapper();
+			queryWrapperRT.eq(RollClubThreeDetails::getStorageBillId, storageBillInfo.getId());
+			List<RollClubThreeDetails> rollClubThreeDetailsList = rollClubThreeDetailsService.list(queryWrapperRT);
+			if (oConvertUtils.listIsNotEmpty(rollClubThreeDetailsList)){
+				double totalBlankOutputs = rollClubThreeDetailsList.stream().mapToDouble(RollClubThreeDetails::getBlankOutput).sum();
+				BigDecimal bd = BigDecimal.valueOf(totalBlankOutputs).setScale(4, BigDecimal.ROUND_HALF_UP);
+				storageCarLog.setFixedWeight(bd.doubleValue());
+			}
+		}else if ("上若".equals(storageBillInfo.getDestination())) {
+			LambdaQueryWrapper<RollOutShippDetails> queryWrapperROS = new LambdaQueryWrapper();
+			queryWrapperROS.eq(RollOutShippDetails::getStorageBillId, storageBillInfo.getId());
+			List<RollOutShippDetails> rollOutShippDetailsList = rollOutShippDetailsService.list(queryWrapperROS);
+			if (oConvertUtils.listIsNotEmpty(rollOutShippDetailsList)){
+				double totalBlankOutputs = rollOutShippDetailsList.stream().mapToDouble(RollOutShippDetails::getBlankOutput).sum();
+				BigDecimal bd = BigDecimal.valueOf(totalBlankOutputs).setScale(4, BigDecimal.ROUND_HALF_UP);
+				storageCarLog.setFixedWeight(bd.doubleValue());// 定重
+			}
+		}
 		storageCarLog.setTypeConfigId(storageBillInfo.getTypeConfigId()); // 钢坯配置类型ID
 		storageCarLog.setHeatNo(String.join(",", heatNoList));
 		storageCarLog.setSize(String.join(",", sizeList));// 定尺

+ 100 - 3
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetHotsendChangeShift/controller/BilletHotsendChangeShiftController.java

@@ -18,7 +18,10 @@ import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.actualControl.heatsActuals.service.IHeatsActualsService;
 import org.jeecg.modules.billet.billetHotsendChangeShift.entity.BilletHotsendChangeShift;
 import org.jeecg.modules.billet.billetHotsendChangeShift.service.IBilletHotsendChangeShiftService;
+import org.jeecg.modules.billet.billetHotsendChangeShift.util.ScheduleUtils;
 import org.jeecg.modules.billet.operateLog.service.IOperateLogService;
+import org.jeecg.modules.billet.storageBill.entity.ShiftEnum;
+import org.jeecg.modules.billet.storageBill.entity.ShiftGroupEnum;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.web.bind.annotation.*;
@@ -30,9 +33,8 @@ import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.time.YearMonth;
 import java.time.format.DateTimeFormatter;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @Description: 钢坯交班记录
@@ -237,4 +239,99 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
 
 		return Result.OK(pageList);
 	}
+
+
+	// 每天 08:00:00 执行的定时任务
+//	@Scheduled(cron = "0 0 8 * * ?")
+	public void executeDayShiftTask() {
+		log.info("自动化定时交班——白班:08:00:00开始执行!");
+		performShiftChange("白班");
+	}
+
+	// 每天 16:00:00 执行的定时任务
+//	@Scheduled(cron = "0 0 16 * * ?")
+	public void executeMiddleShiftTask() {
+		log.info("自动定时交班——中班:16:00:00开始执行!");
+		performShiftChange("中班");
+	}
+
+	// 每天 00:00:00 执行的定时任务
+//	@Scheduled(cron = "0 0 0 * * ?")
+	public void executeNeightShiftTask() {
+		log.info("自动化定时交班——白班:08:00:00开始执行!");
+		performShiftChange("夜班");
+	}
+
+	@ApiOperation(value="自动化交班测试", notes="自动化交班测试")
+	@GetMapping(value = "/autoByCcmNo")
+	public Result<List<BilletHotsendChangeShift>> autoByCcmNo() {
+		performShiftChange("白班");
+		List<BilletHotsendChangeShift> list = billetHotsendChangeShiftService.list().stream()
+				.sorted(Comparator.comparing(BilletHotsendChangeShift::getCreateTime).reversed())
+				.limit(2)
+				.collect(Collectors.toList());
+		return Result.OK(list);
+	}
+	/**
+	 * 自动化交班
+	 * @author: jeecg-boot
+	 * @param shiftName
+	 */
+	private void performShiftChange(String shiftName) {
+
+		String keyShiftGroupfive = String.format("class:shift:group:%s", "5");
+		String keyShiftfive = String.format("class:shift:%s", "5");
+
+		String fiveShiftGroup = oConvertUtils.getString(redisTemplate.opsForValue().get(keyShiftGroupfive));
+		String fiveShift = oConvertUtils.getString(redisTemplate.opsForValue().get(keyShiftfive));
+
+		String keyShiftGroupsix = String.format("class:shift:group:%s", "6");
+		String keyShiftsix = String.format("class:shift:%s", "6");
+
+		String sixShiftGroup = oConvertUtils.getString(redisTemplate.opsForValue().get(keyShiftGroupsix));
+		String sixShift = oConvertUtils.getString(redisTemplate.opsForValue().get(keyShiftsix));
+
+
+		// 5.6号机的班组和班别是否相等
+		if (!Objects.equals(sixShiftGroup, fiveShiftGroup) || !Objects.equals(sixShift, fiveShift)) {
+			log.info("缓存中5.6号机的当班班组信息不一致,执行交班定时任务失败! {}", new Date());
+			log.info("5号机班组值:{},6号机班组值:{}", fiveShiftGroup, sixShiftGroup);
+			log.info("5号机班别值:{},6号机班别值:{}", fiveShift, sixShift);
+			return;
+		}
+
+		String currentShiftGroupName = ShiftGroupEnum.fromCode(sixShiftGroup).name();
+		String currentShiftName = ShiftEnum.fromCode(sixShift).name().replace("班", "");
+
+		String[] result = ScheduleUtils.getNextShiftInfo(currentShiftGroupName, currentShiftName);
+		if (result.length < 4 || result[2] == null || result[3] == null) {
+			log.info("根据排班表未匹配出下一个班次信息,自动化交班失败! {}", new Date());
+			return;
+		}
+		log.info("下一个班次信息:{}——{}", result[0], result[1]);
+		log.info("下一个班次信息:{}——{}", result[3], result[2]);
+
+		// 查询当天的交班记录
+		LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapperCS = new LambdaQueryWrapper<>();
+		queryWrapperCS.between(BilletHotsendChangeShift::getCreateTime, DateUtils.getStartOfDay(), DateUtils.getEndOfDay());
+		List<BilletHotsendChangeShift> billetHotsendChangeShiftList = billetHotsendChangeShiftService.list(queryWrapperCS);
+
+		String nextShift = String.join(",", result[3], result[2]);
+
+		if (oConvertUtils.listIsNotEmpty(billetHotsendChangeShiftList)) {
+			boolean exists = billetHotsendChangeShiftList.stream()
+					.map(x -> String.join(",", x.getShift(), x.getShiftGroup()))
+					.anyMatch(s -> s.equals(nextShift));
+			if (exists) {
+				log.info("自动化当天不能重复交班! {}", new Date());
+				return;
+			}
+		}
+
+		BilletHotsendChangeShift billetHotsendChangeShiftVo = new BilletHotsendChangeShift();
+		billetHotsendChangeShiftVo.setShiftGroup(result[2]);
+		billetHotsendChangeShiftVo.setShift(result[3]);
+		JSONObject jsonObject = billetHotsendChangeShiftService.autoChangeShiftHandle(billetHotsendChangeShiftVo);
+		log.info("自动化{}交班成功! {} 结果值:{}", shiftName, new Date(), jsonObject);
+	}
 }

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

@@ -13,4 +13,6 @@ import org.jeecg.modules.billet.billetHotsendChangeShift.entity.BilletHotsendCha
 public interface IBilletHotsendChangeShiftService extends IService<BilletHotsendChangeShift> {
 
     JSONObject billetHotsendChangeShiftHandle(BilletHotsendChangeShift billetHotsendChangeShiftVo);
+
+    JSONObject autoChangeShiftHandle(BilletHotsendChangeShift billetHotsendChangeShiftVo);
 }

+ 89 - 1
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetHotsendChangeShift/service/impl/BilletHotsendChangeShiftServiceImpl.java

@@ -134,6 +134,95 @@ public class BilletHotsendChangeShiftServiceImpl extends ServiceImpl<BilletHotse
         return result;
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public JSONObject autoChangeShiftHandle(BilletHotsendChangeShift billetHotsendChangeShiftVo) {
+        JSONObject result = new JSONObject();
+
+        List<String> ccmNoList = Arrays.asList("5", "6");
+        for (String ccmNo : ccmNoList){
+            String keyShiftGroup = String.format("class:shift:group:%s", ccmNo);
+            String keyShift = String.format("class:shift:%s", ccmNo);
+            // 保存旧的缓存值,用于异常回滚
+            String oldShiftGroup = Optional.ofNullable(redisTemplate.opsForValue().get(keyShiftGroup))
+                    .map(Object::toString)
+                    .orElse(null);
+            String oldShift = Optional.ofNullable(redisTemplate.opsForValue().get(keyShift))
+                    .map(Object::toString)
+                    .orElse(null);
+            try {
+                // 先更新班组班别缓存
+                redisTemplate.opsForValue().set(keyShiftGroup, billetHotsendChangeShiftVo.getShiftGroup());
+                redisTemplate.opsForValue().set(keyShift, billetHotsendChangeShiftVo.getShift());
+
+                // 获取当前班组班别
+                BilletHotsendChangeShift billetHotsendChangeShift = baseMapper.selectOne(new LambdaQueryWrapper<BilletHotsendChangeShift>()
+                        .eq(BilletHotsendChangeShift::getCcmNo, ccmNo)
+                        .orderByDesc(BilletHotsendChangeShift::getCreateTime)
+                        .last("limit 1"));
+                if (oConvertUtils.isEmpty(billetHotsendChangeShift)) {
+                    result.put("fail", "当班信息查询为空,自动化交班操作失败!");
+                    return result;
+                }
+                // 更新当前班次的交班时间,相当于上一个班交班的结束时间
+                billetHotsendChangeShift.setChangeShiftTime(new Date());
+                billetHotsendChangeShift.setUpdateTime(new Date());
+                baseMapper.updateById(billetHotsendChangeShift);
+                // 获取当前最新炉号
+                if (oConvertUtils.isNotEmpty(billetHotsendChangeShift.getHeatNo())) {
+                    // 根据当前炉号、铸机号、班组、班别查询总生产的钢坯数
+                    LambdaQueryWrapper<BilletBasicInfo> queryWrapper = new LambdaQueryWrapper<BilletBasicInfo>()
+                            .eq(BilletBasicInfo::getCcmNo, Integer.valueOf(ccmNo))
+                            .eq(BilletBasicInfo::getHeatNo, billetHotsendChangeShift.getHeatNo())
+                            .eq(BilletBasicInfo::getShift, billetHotsendChangeShift.getShift())
+                            .eq(BilletBasicInfo::getShiftGroup, billetHotsendChangeShift.getShiftGroup())
+                            .isNull(BilletBasicInfo::getBelongTable)
+                            .isNull(BilletBasicInfo::getBhtcId)
+                            .orderByAsc(BilletBasicInfo::getCreateTime);
+                    List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(queryWrapper);
+                    List<BilletBasicInfo> updateBilletBasicInfo = extractRemainderData(billetBasicInfoList);
+                    if (oConvertUtils.listIsNotEmpty(updateBilletBasicInfo)){
+                        updateBilletBasicInfo.forEach(x -> {
+                            x.setShift(billetHotsendChangeShiftVo.getShift());
+                            x.setShiftGroup(billetHotsendChangeShiftVo.getShiftGroup());
+                            x.setUpdateTime(new Date());
+                        });
+                        log.info("自动化交班判定该钢坯到新的班组:{}", JSON.toJSON(updateBilletBasicInfo) + "操作时间" + new Date());
+                        billetBasicInfoService.saveOrUpdateBatch(updateBilletBasicInfo);
+                    }
+                }
+
+                // 生成新的交班记录 初始化并保存入库
+                BilletHotsendChangeShift billetHotsendChangeShift1 = new BilletHotsendChangeShift();
+                billetHotsendChangeShift1.setId(String.valueOf(IdWorker.getId()));
+                billetHotsendChangeShift1.setCcmNo(ccmNo);
+                billetHotsendChangeShift1.setShift(billetHotsendChangeShiftVo.getShift());
+                billetHotsendChangeShift1.setShiftGroup(billetHotsendChangeShiftVo.getShiftGroup());
+                billetHotsendChangeShift1.setHotfeignAmount(0); // 当前热装支数
+                billetHotsendChangeShift1.setProductAmount(0); // 当前生产支数
+                billetHotsendChangeShift1.setHotsendAmount(0); // 当前热送支数
+                billetHotsendChangeShift1.setStackAmount(0); // 当前起垛支数
+                billetHotsendChangeShift1.setOutCarNum(0); // 车次
+                billetHotsendChangeShift1.setShiftSum(0); // 当班总数
+                billetHotsendChangeShift1.setShiftProduct(0d); // 当班总重
+                billetHotsendChangeShift1.setWasteAmount(0); // 当前废品支数
+                billetHotsendChangeShift1.setCreateTime(new Date());
+                baseMapper.insert(billetHotsendChangeShift1);
+                operateLogService.add(billetHotsendChangeShift1, null, BilletHotsendChangeShift.class);
+                result.put("success", "自动化交班操作成功!");
+            } catch (Exception e) {
+                log.error("自动化交班操作出现异常", e);
+                // 回滚缓存
+                if (oldShiftGroup != null && oldShift != null) {
+                    redisTemplate.opsForValue().set(keyShiftGroup, oldShiftGroup);
+                    redisTemplate.opsForValue().set(keyShift, oldShift);
+                }
+                result.put("fail", "自动化交班操作失败,出现异常!");
+            }
+        }
+        return result;
+    }
+
     /**
      * 计算余数并提取相应元素
      * @param billetBasicInfoList
@@ -147,5 +236,4 @@ public class BilletHotsendChangeShiftServiceImpl extends ServiceImpl<BilletHotse
         }
         return new ArrayList<>();
     }
-
 }

+ 73 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetHotsendChangeShift/util/ScheduleRecord.java

@@ -0,0 +1,73 @@
+package org.jeecg.modules.billet.billetHotsendChangeShift.util;
+
+import lombok.Data;
+
+@Data
+public class ScheduleRecord {
+
+    private String shiftGroup; // 人员,如甲、乙、丙、丁
+
+    private String shift;      // 班次,如白、中、夜
+
+    private String startTime;  // 班次开始时间
+
+    private String endTime;    //
+
+    public ScheduleRecord(String shiftGroup, String shift) {
+        this.shiftGroup = shiftGroup;
+        this.shift = shift;
+        // 根据班次设置开始和结束时间
+        switch (shift) {
+            case "白":
+                this.startTime = "00:00:00";
+                this.endTime = "08:00:00";
+                break;
+            case "中":
+                this.startTime = "08:00:01";
+                this.endTime = "16:00:00";
+                break;
+            case "夜":
+                this.startTime = "16:00:01";
+                this.endTime = "00:00:00";
+                break;
+            default:
+                this.startTime = "";
+                this.endTime = "";
+        }
+    }
+
+    // 获取人员对应的值
+    public int getShiftGroupValue() {
+        switch (shiftGroup) {
+            case "甲":
+                return 0;
+            case "乙":
+                return 1;
+            case "丙":
+                return 2;
+            case "丁":
+                return 3;
+            default:
+                return -1;
+        }
+    }
+
+    // 获取班次对应的值
+    public int getShiftValue() {
+        switch (shift) {
+            case "白":
+                return 0;
+            case "中":
+                return 2;
+            case "夜":
+                return 1;
+            default:
+                return -1;
+        }
+    }
+
+    @Override
+    public String toString() {
+        return "人员: " + shiftGroup + "(" + getShiftGroupValue() + "), 班次: " + shift + "(" + getShiftValue() + "), 时段: " + startTime + " - " + endTime;
+    }
+}

+ 102 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetHotsendChangeShift/util/ScheduleUtils.java

@@ -0,0 +1,102 @@
+package org.jeecg.modules.billet.billetHotsendChangeShift.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ScheduleUtils {
+
+    public static String[] getNextShiftInfo(String currentShiftGroup, String currentShift) {
+
+        List<ScheduleRecord> scheduleRecords = new ArrayList<>();
+        scheduleRecords.add(new ScheduleRecord("甲", "白"));
+        scheduleRecords.add(new ScheduleRecord("乙", "中"));
+        scheduleRecords.add(new ScheduleRecord("丙", "夜"));
+        scheduleRecords.add(new ScheduleRecord("甲", "白"));
+        scheduleRecords.add(new ScheduleRecord("乙", "中"));
+        scheduleRecords.add(new ScheduleRecord("丙", "夜"));
+        scheduleRecords.add(new ScheduleRecord("甲", "白"));
+        scheduleRecords.add(new ScheduleRecord("乙", "中"));
+        scheduleRecords.add(new ScheduleRecord("丙", "夜"));
+        scheduleRecords.add(new ScheduleRecord("甲", "白"));
+        scheduleRecords.add(new ScheduleRecord("乙", "中"));
+        scheduleRecords.add(new ScheduleRecord("丁", "夜"));
+        scheduleRecords.add(new ScheduleRecord("丙", "白"));
+        scheduleRecords.add(new ScheduleRecord("甲", "中"));
+        scheduleRecords.add(new ScheduleRecord("丁", "夜"));
+        scheduleRecords.add(new ScheduleRecord("丙", "白"));
+        scheduleRecords.add(new ScheduleRecord("甲", "中"));
+        scheduleRecords.add(new ScheduleRecord("丁", "夜"));
+        scheduleRecords.add(new ScheduleRecord("丙", "白"));
+        scheduleRecords.add(new ScheduleRecord("甲", "中"));
+        scheduleRecords.add(new ScheduleRecord("丁", "夜"));
+        scheduleRecords.add(new ScheduleRecord("丙", "白"));
+        scheduleRecords.add(new ScheduleRecord("甲", "中"));
+        scheduleRecords.add(new ScheduleRecord("乙", "夜"));
+        scheduleRecords.add(new ScheduleRecord("丁", "白"));
+        scheduleRecords.add(new ScheduleRecord("丙", "中"));
+        scheduleRecords.add(new ScheduleRecord("乙", "夜"));
+        scheduleRecords.add(new ScheduleRecord("丁", "白"));
+        scheduleRecords.add(new ScheduleRecord("丙", "中"));
+        scheduleRecords.add(new ScheduleRecord("乙", "夜"));
+        scheduleRecords.add(new ScheduleRecord("丁", "白"));
+        scheduleRecords.add(new ScheduleRecord("丙", "中"));
+        scheduleRecords.add(new ScheduleRecord("乙", "夜"));
+        scheduleRecords.add(new ScheduleRecord("丁", "白"));
+        scheduleRecords.add(new ScheduleRecord("丙", "中"));
+        scheduleRecords.add(new ScheduleRecord("甲", "夜"));
+        scheduleRecords.add(new ScheduleRecord("乙", "白"));
+        scheduleRecords.add(new ScheduleRecord("丁", "中"));
+        scheduleRecords.add(new ScheduleRecord("甲", "夜"));
+        scheduleRecords.add(new ScheduleRecord("乙", "白"));
+        scheduleRecords.add(new ScheduleRecord("丁", "中"));
+        scheduleRecords.add(new ScheduleRecord("甲", "夜"));
+        scheduleRecords.add(new ScheduleRecord("乙", "白"));
+        scheduleRecords.add(new ScheduleRecord("丁", "中"));
+        scheduleRecords.add(new ScheduleRecord("甲", "夜"));
+        scheduleRecords.add(new ScheduleRecord("乙", "白"));
+        scheduleRecords.add(new ScheduleRecord("丁", "中"));
+
+        // 假设存储下一个班次的名称和值信息
+        String nextShiftGroupName = "";
+        String nextShiftName = "";
+        String nextShiftGroupValue = "";
+        String nextShiftValue = "";
+        // 找到当前班次在排班表中的位置
+        int currentIndex = -1;
+        for (int i = 0; i < scheduleRecords.size(); i++) {
+            ScheduleRecord record = scheduleRecords.get(i);
+            if (record.getShift().equals(currentShift) && record.getShiftGroup().equals(currentShiftGroup)) {
+                currentIndex = i;
+                break;
+            }
+        }
+
+        if (currentIndex != -1) {
+            // 输出接下来的一个班次信息
+            int nextIndex = (currentIndex + 1) % scheduleRecords.size();
+            ScheduleRecord nextRecord = scheduleRecords.get(nextIndex);
+            nextShiftGroupName = nextRecord.getShiftGroup();
+            nextShiftName = nextRecord.getShift();
+            nextShiftGroupValue = String.valueOf(nextRecord.getShiftGroupValue());
+            nextShiftValue = String.valueOf(nextRecord.getShiftValue());
+        } else {
+            nextShiftGroupValue = null;
+            nextShiftValue = null;
+        }
+        return new String[]{nextShiftGroupName, nextShiftName, nextShiftGroupValue, nextShiftValue};
+    }
+
+
+//    public static void main(String[] args) {
+//        String[] result = getNextShiftInfo("甲", "白");
+//        //判断班组值和班别值是否为空
+//        if (result[2] == null || result[3] == null) {
+//            System.out.println("找不到下一个班次信息,自动化交班失败!");
+//            return;
+//        }
+//        System.out.println("下一个班组:" + result[0]);
+//        System.out.println("下一个班别:" + result[1]);
+//        System.out.println("下一个班组值:" + result[2]);
+//        System.out.println("下一个班别值:" + result[3]);
+//    }
+}

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

@@ -56,6 +56,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -666,7 +667,6 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
             return result;
 
         }
-        // 6 更新装运单 storage_bill 取最新的第一条钢坯信息更新钢种和规格
 
         // 根据装运单ID查询装运单信息
         StorageBill storageBillInfo = storageBillService.getById(storageBill.getId());
@@ -701,19 +701,44 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
         StorageCarLog storageCarLog = new StorageCarLog();
         BeanUtils.copyProperties(storageBillInfo, storageCarLog);
 
-        LambdaQueryWrapper<StackingDownLog> queryWrappersd = new LambdaQueryWrapper();
-        queryWrappersd.eq(StackingDownLog::getCcmNo, storageBill.getCcmNo()).eq(StackingDownLog::getStorageBillId, storageBill.getId());
-        List<StackingDownLog> stackingDownLogs = stackingDownLogService.list(queryWrappersd);
-
-        Integer bx = Integer.valueOf((int) count);
-        Integer dd = stackingDownLogs.size() * 4 + bx;
         storageCarLog.setDestination(storageBillInfo.getDestination());// 目的地
         storageCarLog.setCarNm(storageBillInfo.getLicensePlate());// 车牌号
         storageCarLog.setTypeConfigId(storageBillInfo.getTypeConfigId()); // 钢坯配置类型ID
         storageCarLog.setHeatNo(String.join(",", heatNoList));
         storageCarLog.setSize(String.join(",", sizeList));// 定尺
-        storageCarLog.setAmount(dd);// 支数
+        storageCarLog.setAmount(storageBillInfo.getAmountTotal());// 支数
         storageCarLog.setDataTime(new Date());
+        if("棒二".equals(storageBillInfo.getDestination())){
+            // 根据装运单ID,查询棒二明细表
+            LambdaQueryWrapper<RollClubTwoDetails> queryWrapperRC = new LambdaQueryWrapper();
+            queryWrapperRC.eq(RollClubTwoDetails::getStorageBillId, storageBillInfo.getId());
+            List<RollClubTwoDetails> rollClubTwoDetailsList = rollClubTwoDetailsService.list(queryWrapperRC);
+            if (oConvertUtils.listIsNotEmpty(rollClubTwoDetailsList)){
+                double totalBlankOutputs = rollClubTwoDetailsList.stream().mapToDouble(RollClubTwoDetails::getBlankOutput).sum();
+                BigDecimal bd = BigDecimal.valueOf(totalBlankOutputs).setScale(4, BigDecimal.ROUND_HALF_UP);
+                storageCarLog.setFixedWeight(bd.doubleValue());
+            }
+        }else if ("棒三".equals(storageBillInfo.getDestination())) {
+            // 根据装运单ID,查询棒三明细表
+            LambdaQueryWrapper<RollClubThreeDetails> queryWrapperRT = new LambdaQueryWrapper();
+            queryWrapperRT.eq(RollClubThreeDetails::getStorageBillId, storageBillInfo.getId());
+            List<RollClubThreeDetails> rollClubThreeDetailsList = rollClubThreeDetailsService.list(queryWrapperRT);
+            if (oConvertUtils.listIsNotEmpty(rollClubThreeDetailsList)){
+                double totalBlankOutputs = rollClubThreeDetailsList.stream().mapToDouble(RollClubThreeDetails::getBlankOutput).sum();
+                BigDecimal bd = BigDecimal.valueOf(totalBlankOutputs).setScale(4, BigDecimal.ROUND_HALF_UP);
+                storageCarLog.setFixedWeight(bd.doubleValue());
+            }
+        }else if ("上若".equals(storageBillInfo.getDestination())) {
+            // 根据装运单ID,查询上若明细表
+            LambdaQueryWrapper<RollOutShippDetails> queryWrapperROS = new LambdaQueryWrapper();
+            queryWrapperROS.eq(RollOutShippDetails::getStorageBillId, storageBillInfo.getId());
+            List<RollOutShippDetails> rollOutShippDetailsList = rollOutShippDetailsService.list(queryWrapperROS);
+            if (oConvertUtils.listIsNotEmpty(rollOutShippDetailsList)){
+                double totalBlankOutputs = rollOutShippDetailsList.stream().mapToDouble(RollOutShippDetails::getBlankOutput).sum();
+                BigDecimal bd = BigDecimal.valueOf(totalBlankOutputs).setScale(4, BigDecimal.ROUND_HALF_UP);
+                storageCarLog.setFixedWeight(bd.doubleValue());// 定重
+            }
+        }
         storageCarLogService.save(storageCarLog);
         result.put("success", "堆垛发车操作成功");
         return result;

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

@@ -289,10 +289,37 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
 		StorageCarLog storageCarLog = new StorageCarLog();
 		BeanUtils.copyProperties(storageBill, storageCarLog);
 		storageCarLog.setCarNm(storageBill.getLicensePlate());// 车牌号
-//		storageCarLog.setTypeConfigId(billetHotsendTypeConfig.getId()); // 钢坯配置类型ID
-//		storageCarLog.setHeatNo(billetHotsend.getHeatNo());
-//		storageCarLog.setFixedWeight();// 定重
-//      storageCarLog.setSize(storageBill.getSize());// 定尺
+		if("棒二".equals(storageBill.getDestination())){
+			// 根据装运单ID,查询棒二明细表
+			LambdaQueryWrapper<RollClubTwoDetails> queryWrapperRC = new LambdaQueryWrapper();
+			queryWrapperRC.eq(RollClubTwoDetails::getStorageBillId, storageBill.getId());
+			List<RollClubTwoDetails> rollClubTwoDetailsList = rollClubTwoDetailsService.list(queryWrapperRC);
+			if (oConvertUtils.listIsNotEmpty(rollClubTwoDetailsList)){
+				double totalBlankOutputs = rollClubTwoDetailsList.stream().mapToDouble(RollClubTwoDetails::getBlankOutput).sum();
+				BigDecimal bd = BigDecimal.valueOf(totalBlankOutputs).setScale(4, BigDecimal.ROUND_HALF_UP);
+				storageCarLog.setFixedWeight(bd.doubleValue());
+			}
+		}else if ("棒三".equals(storageBill.getDestination())) {
+			// 根据装运单ID,查询棒三明细表
+			LambdaQueryWrapper<RollClubThreeDetails> queryWrapperRT = new LambdaQueryWrapper();
+			queryWrapperRT.eq(RollClubThreeDetails::getStorageBillId, storageBill.getId());
+			List<RollClubThreeDetails> rollClubThreeDetailsList = rollClubThreeDetailsService.list(queryWrapperRT);
+			if (oConvertUtils.listIsNotEmpty(rollClubThreeDetailsList)){
+				double totalBlankOutputs = rollClubThreeDetailsList.stream().mapToDouble(RollClubThreeDetails::getBlankOutput).sum();
+				BigDecimal bd = BigDecimal.valueOf(totalBlankOutputs).setScale(4, BigDecimal.ROUND_HALF_UP);
+				storageCarLog.setFixedWeight(bd.doubleValue());
+			}
+		}else if ("上若".equals(storageBill.getDestination())) {
+			// 根据装运单ID,查询上若明细表
+			LambdaQueryWrapper<RollOutShippDetails> queryWrapperROS = new LambdaQueryWrapper();
+			queryWrapperROS.eq(RollOutShippDetails::getStorageBillId, storageBill.getId());
+			List<RollOutShippDetails> rollOutShippDetailsList = rollOutShippDetailsService.list(queryWrapperROS);
+			if (oConvertUtils.listIsNotEmpty(rollOutShippDetailsList)){
+				double totalBlankOutputs = rollOutShippDetailsList.stream().mapToDouble(RollOutShippDetails::getBlankOutput).sum();
+				BigDecimal bd = BigDecimal.valueOf(totalBlankOutputs).setScale(4, BigDecimal.ROUND_HALF_UP);
+				storageCarLog.setFixedWeight(bd.doubleValue());// 定重
+			}
+		}
 		// 查询上垛记录,计算出总支数
 		storageCarLog.setDataTime(new Date());
 		storageCarLog.setAmount(storageBill.getAmountTotal());// 支数