Forráskód Böngészése

增加当班轧钢-班次工作台接口

lingpeng.li 2 hónapja
szülő
commit
4849911fd8

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

@@ -44,10 +44,7 @@ import org.jeecg.modules.billet.rollOutShipp.service.IRollOutShippDetailsService
 import org.jeecg.modules.billet.storageBill.dto.HotChargingQueryDTO;
 import org.jeecg.modules.billet.storageBill.entity.*;
 import org.jeecg.modules.billet.storageBill.service.IStorageBillService;
-import org.jeecg.modules.billet.storageBill.vo.OnDutyColdChargeVo;
-import org.jeecg.modules.billet.storageBill.vo.OnDutyHotChargeVo;
-import org.jeecg.modules.billet.storageBill.vo.OnDutySizeVo;
-import org.jeecg.modules.billet.storageBill.vo.OnDutyStorageBillVo;
+import org.jeecg.modules.billet.storageBill.vo.*;
 import org.jeecg.modules.billet.storageCarLog.entity.StorageCarLog;
 import org.jeecg.modules.billet.storageCarLog.service.IStorageCarLogService;
 import org.springframework.beans.BeanUtils;
@@ -1402,6 +1399,15 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
 		return Result.OK(result);
 	}
 
+
+	@ApiOperation(value="当班轧钢-班次工作台", notes="当班轧钢-班次工作台")
+	@GetMapping(value = "/queryOnDutySteel")
+	public Result<OnDutySteelVo> queryOnDutySteel(@RequestParam(name="ccmNo") String ccmNo,
+													   @RequestParam(name="changeShiftId", required = false) String changeShiftId) {
+		OnDutySteelVo result = storageBillService.queryOnDutySteel(ccmNo, changeShiftId);
+		return Result.OK(result);
+	}
+
 	/**
 	 * 计算 本车车次
 	 * @param ccmNo

+ 4 - 4
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/storageBill/service/IStorageBillService.java

@@ -5,10 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.actualControl.billetActual.billetActual.entity.BilletBasicInfo;
 import org.jeecg.modules.billet.billetHotsend.entity.BilletHotsendDetailsVo;
 import org.jeecg.modules.billet.storageBill.entity.*;
-import org.jeecg.modules.billet.storageBill.vo.OnDutyColdChargeVo;
-import org.jeecg.modules.billet.storageBill.vo.OnDutyHotChargeVo;
-import org.jeecg.modules.billet.storageBill.vo.OnDutySizeVo;
-import org.jeecg.modules.billet.storageBill.vo.OnDutyStorageBillVo;
+import org.jeecg.modules.billet.storageBill.vo.*;
 
 import java.util.List;
 import java.util.Map;
@@ -78,4 +75,7 @@ public interface IStorageBillService extends IService<StorageBill> {
     OnDutyHotChargeVo queryOnDutyHotCharge(String ccmNo);
 
     OnDutyColdChargeVo queryOnDutyColdCharge(String ccmNo);
+
+    OnDutySteelVo queryOnDutySteel(String ccmNo,String changeShiftId);
+
 }

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

@@ -2073,7 +2073,7 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
             queryWrapper4.between(RollHeightDetails::getCreateTime, billetHotsendChangeShift.getCreateTime(), billetHotsendChangeShift.getChangeShiftTime());
         }
         List<RollHeightDetails> rollHeightDetailsList = rollHeightDetailsService.list(queryWrapper4);
-        if (oConvertUtils.listIsNotEmpty(rollClubTwoDetailsList)){
+        if (oConvertUtils.listIsNotEmpty(rollHeightDetailsList)){
             // 高线总支数    高线属于热送
             int hotSendHeightSum = rollHeightDetailsList.stream()
                     .mapToInt(details -> details.getStackAddr() != null && !details.getStackAddr().isEmpty() ? 4 : 1).sum();
@@ -3884,6 +3884,258 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
         return onDutyColdChargeVo;
     }
 
+    @Override
+    public OnDutySteelVo queryOnDutySteel(String ccmNo,String changeShiftId) {
+
+        OnDutySteelVo onDutySteelVo = new OnDutySteelVo();
+
+        String shiftGroup = "";
+        String shift = "";
+        BilletHotsendChangeShift billetHotsendChangeShift;
+        if(oConvertUtils.isEmpty(changeShiftId)){
+            // 从 Redis 获取班次信息
+            shiftGroup = getShiftInfo(ccmNo, "class:shift:group:%s");
+            shift = getShiftInfo(ccmNo, "class:shift:%s");
+            // 根据铸机号、缓存中的当前班次,倒序最新一条,获取交班记录中的创建时间
+            LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(BilletHotsendChangeShift::getCcmNo, ccmNo)
+                    .eq(BilletHotsendChangeShift::getShift, shift)
+                    .eq(BilletHotsendChangeShift::getShiftGroup, shiftGroup)
+                    .orderByDesc(BilletHotsendChangeShift::getCreateTime)
+                    .last("limit 1");
+            billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapper);
+            if (billetHotsendChangeShift == null){
+                log.info("{}{}", "查询当班装运单信息失败,交班记录为空!", ccmNo + "失败时间:" + new Date());
+                return onDutySteelVo;
+            }
+        }else {
+            // 根据铸机号、交班记录ID,获取交班记录中的班别、班次、创建时间
+            LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(BilletHotsendChangeShift::getId, changeShiftId).eq(BilletHotsendChangeShift::getCcmNo, ccmNo);
+            billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapper);
+            if (billetHotsendChangeShift == null){
+                log.info("{}{}", "查询历史当班装运单信息失败,交班记录为空!", ccmNo + "失败时间:" + new Date());
+                return onDutySteelVo;
+            }
+            shiftGroup = billetHotsendChangeShift.getShiftGroup();
+            shift = billetHotsendChangeShift.getShift();
+        }
+
+
+        // 根据铸机号、班组、班别,amountTotal不等于0 ,查询当班装运单信息
+        LambdaQueryWrapper<StorageBill> queryWrapper2 = new LambdaQueryWrapper<>();
+        queryWrapper2.eq(StorageBill::getCcmNo, ccmNo)
+                .gt(StorageBill::getAmountTotal, 0);
+        // 检查 billetHotsendChangeShift 是否为空
+        if (oConvertUtils.isEmpty(changeShiftId)) {
+            // 当 changeShiftId 为空时,时间范围从 createTime 到当前时间
+            queryWrapper2.between(StorageBill::getCreateTime, billetHotsendChangeShift.getCreateTime(), new Date());
+        } else {
+            // 当 changeShiftId 不为空时,时间范围从 createTime 到 updateTime
+            queryWrapper2.between(StorageBill::getCreateTime, billetHotsendChangeShift.getCreateTime(), billetHotsendChangeShift.getChangeShiftTime());
+        }
+        List<StorageBill> storageBillList = baseMapper.selectList(queryWrapper2);
+        if (oConvertUtils.listIsEmpty(storageBillList)){
+            log.info("{}{}", "查询当班装运单信息为空!", ccmNo);
+        }
+
+        List<SizeSummary> rollClubOneList = new ArrayList<>();
+        List<SizeSummary> rollClubTwoList = new ArrayList<>();
+        List<SizeSummary> rollClubThreeList = new ArrayList<>();
+        List<SizeSummary> rollHeightList = new ArrayList<>();
+        List<SizeSummary> rollOutShippList = new ArrayList<>();
+
+        if(oConvertUtils.listIsNotEmpty(storageBillList)) {
+            for (StorageBill storageBill : storageBillList) {
+                if ("棒二".equals(storageBill.getDestination())) {
+                    LambdaQueryWrapper<RollClubTwoDetails> queryWrapper3 = new LambdaQueryWrapper<>();
+                    queryWrapper3.eq(RollClubTwoDetails::getCcmNo, ccmNo).eq(RollClubTwoDetails::getStorageBillId, storageBill.getId());
+                    List<RollClubTwoDetails> rollClubTwoDetailsList = rollClubTwoDetailsService.list(queryWrapper3);
+                    if (oConvertUtils.listIsNotEmpty(rollClubTwoDetailsList)) {
+                        List<SizeSummary> currentList1 = rollClubTwoDetailsList.stream()
+                                .collect(Collectors.groupingBy(RollClubTwoDetails::getSize))
+                                .entrySet().stream()
+                                .map(entry -> {
+                                    String size = entry.getKey();
+                                    List<RollClubTwoDetails> group = entry.getValue();
+                                    // 统计 blankOutput 总和
+                                    BigDecimal totalBlankOutput = group.stream()
+                                            .map(RollClubTwoDetails::getBlankOutput)
+                                            .filter(Objects::nonNull) // 过滤 null 值
+                                            .map(BigDecimal::valueOf) // Double 转 BigDecimal
+                                            .reduce(BigDecimal.ZERO, BigDecimal::add);
+                                    // 统计数量
+                                    Integer totalNums = group.stream()
+                                            .mapToInt(detail -> detail.getStackAddr() != null ? 4 : 1).sum();
+                                    return new SizeSummary(size, totalNums, totalBlankOutput);
+                                }).collect(Collectors.toList());
+                        rollClubTwoList.addAll(currentList1);
+                    }
+                }
+
+                if ("棒三".equals(storageBill.getDestination())) {
+                    LambdaQueryWrapper<RollClubThreeDetails> queryWrapper3 = new LambdaQueryWrapper<>();
+                    queryWrapper3.eq(RollClubThreeDetails::getCcmNo, ccmNo).eq(RollClubThreeDetails::getStorageBillId, storageBill.getId());
+                    List<RollClubThreeDetails> rollClubThreeDetailsList = rollClubThreeDetailsService.list(queryWrapper3);
+                    if (oConvertUtils.listIsNotEmpty(rollClubThreeDetailsList)) {
+                        List<SizeSummary> currentList2 = rollClubThreeDetailsList.stream()
+                                .collect(Collectors.groupingBy(RollClubThreeDetails::getSize))
+                                .entrySet().stream()
+                                .map(entry -> {
+                                    String size = entry.getKey();
+                                    List<RollClubThreeDetails> group = entry.getValue();
+                                    // 统计 blankOutput 总和
+                                    BigDecimal totalBlankOutput = group.stream()
+                                            .map(RollClubThreeDetails::getBlankOutput)
+                                            .filter(Objects::nonNull) // 过滤 null 值
+                                            .map(BigDecimal::valueOf) // Double 转 BigDecimal
+                                            .reduce(BigDecimal.ZERO, BigDecimal::add);
+                                    // 统计数量
+                                    Integer totalNums = group.stream()
+                                            .mapToInt(detail -> detail.getStackAddr() != null ? 4 : 1).sum();
+                                    return new SizeSummary(size, totalNums, totalBlankOutput);
+                                }).collect(Collectors.toList());
+                        rollClubThreeList.addAll(currentList2);
+                    }
+                }
+
+                if ("上若".equals(storageBill.getDestination())) {
+                    LambdaQueryWrapper<RollOutShippDetails> queryWrapper3 = new LambdaQueryWrapper<>();
+                    queryWrapper3.eq(RollOutShippDetails::getCcmNo, ccmNo).eq(RollOutShippDetails::getStorageBillId, storageBill.getId());
+                    List<RollOutShippDetails> rollOutShippDetailsList = rollOutShippDetailsService.list(queryWrapper3);
+                    if (oConvertUtils.listIsNotEmpty(rollOutShippDetailsList)) {
+                        List<SizeSummary> currentList3 = rollOutShippDetailsList.stream()
+                                .collect(Collectors.groupingBy(RollOutShippDetails::getSize))
+                                .entrySet().stream()
+                                .map(entry -> {
+                                    String size = entry.getKey();
+                                    List<RollOutShippDetails> group = entry.getValue();
+
+                                    // 累加 BlankOutput (转换为 BigDecimal)
+                                    BigDecimal totalBlankOutput = group.stream()
+                                            .map(RollOutShippDetails::getBlankOutput)
+                                            .filter(Objects::nonNull) // 过滤 null 值
+                                            .map(BigDecimal::valueOf) // Double 转 BigDecimal
+                                            .reduce(BigDecimal.ZERO, BigDecimal::add);
+                                    // 统计数量
+                                    Integer totalNums = group.stream()
+                                            .mapToInt(detail -> detail.getStackAddr() != null ? 4 : 1).sum();
+                                    return new SizeSummary(size, totalNums, totalBlankOutput);
+                                }).collect(Collectors.toList());
+                        rollOutShippList.addAll(currentList3);
+                    }
+                }
+            }
+        }
+
+        // 根据铸机号、班组、班别、交班的创建时间,查询棒一符合条件的信息
+        LambdaQueryWrapper<RollClubOneDetails> queryWrapper1 = new LambdaQueryWrapper<>();
+        queryWrapper1.eq(RollClubOneDetails::getCcmNo, ccmNo)
+                .eq(RollClubOneDetails::getShift, shift)
+                .eq(RollClubOneDetails::getShiftGroup, shiftGroup);
+        if (oConvertUtils.isEmpty(changeShiftId)) {
+            // 当 changeShiftId 为空时,时间范围从 createTime 到当前时间
+            queryWrapper1.between(RollClubOneDetails::getCreateTime, billetHotsendChangeShift.getCreateTime(), new Date());
+        } else {
+            // 当 changeShiftId 不为空时,时间范围从 createTime 到 updateTime
+            queryWrapper1.between(RollClubOneDetails::getCreateTime, billetHotsendChangeShift.getCreateTime(), billetHotsendChangeShift.getChangeShiftTime());
+        }
+        List<RollClubOneDetails> list1 = rollClubOneDetailsService.list(queryWrapper1);
+
+        // 根据 size 分组,并统计总支数和总 BlankOutput
+        List<SizeSummary> result1 = list1.stream()
+                .collect(Collectors.groupingBy(RollClubOneDetails::getSize))
+                .entrySet().stream()
+                .map(entry -> {
+                    String size = entry.getKey();
+                    List<RollClubOneDetails> group = entry.getValue();
+
+                    // 统计总支数
+                    int totalNums = group.size();
+
+                    // 累加 BlankOutput (转换为 BigDecimal)
+                    BigDecimal totalBlankOutput = group.stream()
+                            .map(RollClubOneDetails::getBlankOutput)
+                            .filter(Objects::nonNull) // 过滤 null 值
+                            .map(BigDecimal::valueOf) // Double 转 BigDecimal
+                            .reduce(BigDecimal.ZERO, BigDecimal::add);
+
+                    // 返回处理后的分组结果
+                    return new SizeSummary(size, totalNums, totalBlankOutput);
+                }).collect(Collectors.toList());
+
+        rollClubOneList.addAll(result1);
+
+        // 根据铸机号、班组、班别、交班的创建时间,查询高线符合条件的信息
+        LambdaQueryWrapper<RollHeightDetails> queryWrapper4 = new LambdaQueryWrapper<>();
+        queryWrapper4.eq(RollHeightDetails::getCcmNo, ccmNo)
+                .eq(RollHeightDetails::getShift, shift)
+                .eq(RollHeightDetails::getShiftGroup, shiftGroup);
+        if (oConvertUtils.isEmpty(changeShiftId)) {
+            // 当 changeShiftId 为空时,时间范围从 createTime 到当前时间
+            queryWrapper4.between(RollHeightDetails::getCreateTime, billetHotsendChangeShift.getCreateTime(), new Date());
+        } else {
+            // 当 changeShiftId 不为空时,时间范围从 createTime 到 updateTime
+            queryWrapper4.between(RollHeightDetails::getCreateTime, billetHotsendChangeShift.getCreateTime(), billetHotsendChangeShift.getChangeShiftTime());
+        }
+        List<RollHeightDetails> list4 = rollHeightDetailsService.list(queryWrapper4);
+
+        // 根据 size 分组,并统计总支数和总 BlankOutput
+        List<SizeSummary> result4 = list4.stream()
+                .collect(Collectors.groupingBy(RollHeightDetails::getSize))
+                .entrySet().stream()
+                .map(entry -> {
+                    String size = entry.getKey();
+                    List<RollHeightDetails> group = entry.getValue();
+
+                    // 统计总支数,如果 stackAddr 不为空,则乘以 4
+                    int totalNums = group.stream()
+                            .mapToInt(detail -> (detail.getStackAddr() != null && !detail.getStackAddr().isEmpty()) ? 4 : 1)
+                            .sum();
+
+                    // 累加 BlankOutput (转换为 BigDecimal)
+                    BigDecimal totalBlankOutput = group.stream()
+                            .map(RollHeightDetails::getBlankOutput)
+                            .filter(Objects::nonNull) // 过滤 null 值
+                            .map(BigDecimal::valueOf) // Double 转 BigDecimal
+                            .reduce(BigDecimal.ZERO, BigDecimal::add);
+
+                    // 返回处理后的分组结果
+                    return new SizeSummary(size, totalNums, totalBlankOutput);
+                }).collect(Collectors.toList());
+
+        rollHeightList.addAll(result4);
+
+
+
+        onDutySteelVo.setRollClubOneList(mergeSizeSummaryList(rollClubOneList));
+        onDutySteelVo.setRollClubTwoList(mergeSizeSummaryList(rollClubTwoList));
+        onDutySteelVo.setRollClubThreeList(mergeSizeSummaryList(rollClubThreeList));
+        onDutySteelVo.setRollHeightList(mergeSizeSummaryList(rollHeightList));
+        onDutySteelVo.setRollOutShippList(mergeSizeSummaryList(rollOutShippList));
+
+        return onDutySteelVo;
+    }
+
+    /**
+     * 按 size 分组并合并相同 size 的数据
+     */
+    public  List<SizeSummary> mergeSizeSummaryList(List<SizeSummary> list) {
+        return list.stream()
+                .collect(Collectors.toMap(
+                        SizeSummary::getSize,
+                        s -> new SizeSummary(s.getSize(), s.getAmountTotal(), s.getTotalBlankOutput()),
+                        (s1, s2) -> new SizeSummary(
+                                s1.getSize(),
+                                s1.getAmountTotal() + s2.getAmountTotal(),
+                                s1.getTotalBlankOutput().add(s2.getTotalBlankOutput())
+                        )
+                ))
+                .values()
+                .stream()
+                .collect(Collectors.toList());
+    }
+
 
     public void processRollClubOneDetails(List<RollClubOneDetails> rollClubOneDetailsList) {
         if (CollectionUtils.isEmpty(rollClubOneDetailsList)) {

+ 20 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/storageBill/vo/OnDutySteelVo.java

@@ -0,0 +1,20 @@
+package org.jeecg.modules.billet.storageBill.vo;
+
+import lombok.Data;
+import org.jeecg.modules.billet.storageBill.entity.DetailStatistics;
+
+import java.util.List;
+
+@Data
+public class OnDutySteelVo {
+
+    private List<SizeSummary> rollClubOneList;
+
+    private List<SizeSummary> rollClubTwoList;
+
+    private List<SizeSummary> rollClubThreeList;
+
+    private List<SizeSummary> rollHeightList;
+
+    private List<SizeSummary> rollOutShippList;
+}