|
@@ -9,7 +9,6 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
import org.jeecg.modules.actualControl.billetActual.billetActual.entity.BilletBasicInfo;
|
|
@@ -1460,6 +1459,7 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
|
|
|
queryWrapper2.eq(StorageBill::getCcmNo, ccmNo)
|
|
|
.eq(StorageBill::getShift, shift)
|
|
|
.eq(StorageBill::getShiftGroup, shiftGroup)
|
|
|
+ .notIn(StorageBill::getLicensePlate, Arrays.asList("辊道", "堆垛辊道"))
|
|
|
.isNull(StorageBill::getOutTime);
|
|
|
// 检查 billetHotsendChangeShift 是否为空
|
|
|
if (oConvertUtils.isEmpty(changeShiftId)) {
|
|
@@ -1577,6 +1577,7 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
|
|
|
queryWrapper2.eq(StorageBill::getCcmNo, ccmNo)
|
|
|
.eq(StorageBill::getShift, shift)
|
|
|
.eq(StorageBill::getShiftGroup, shiftGroup)
|
|
|
+ .notIn(StorageBill::getLicensePlate, Arrays.asList("辊道", "堆垛辊道"))
|
|
|
.gt(StorageBill::getAmountTotal, 0);
|
|
|
// 检查 billetHotsendChangeShift 是否为空
|
|
|
if (oConvertUtils.isEmpty(changeShiftId)) {
|
|
@@ -2300,6 +2301,230 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
|
|
|
return onDutySizeVoList;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public StorageBillStatistics queryOnDutyStorageBillStatisticsHandle(String ccmNo, String changeShiftId) {
|
|
|
+
|
|
|
+ StorageBillStatistics storageBillStatistics = new StorageBillStatistics();
|
|
|
+
|
|
|
+ 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 storageBillStatistics;
|
|
|
+ }
|
|
|
+ }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 storageBillStatistics;
|
|
|
+ }
|
|
|
+ shiftGroup = billetHotsendChangeShift.getShiftGroup();
|
|
|
+ shift = billetHotsendChangeShift.getShift();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据铸机号、班组、班别,amountTotal不等于0 ,查询当班装运单信息
|
|
|
+ LambdaQueryWrapper<StorageBill> queryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper2.eq(StorageBill::getCcmNo, ccmNo)
|
|
|
+ .eq(StorageBill::getShift, shift)
|
|
|
+ .eq(StorageBill::getShiftGroup, shiftGroup)
|
|
|
+ .notIn(StorageBill::getLicensePlate, Arrays.asList("辊道", "堆垛辊道"))
|
|
|
+ .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);
|
|
|
+ storageBillStatistics.setStorageSum(0);
|
|
|
+ storageBillStatistics.setStorageTotalWeight(0.0);
|
|
|
+ storageBillStatistics.setRollClubTwoSum(0);
|
|
|
+ storageBillStatistics.setRollClubThreeSum(0);
|
|
|
+ storageBillStatistics.setRollClubTwoTotalWeight(0.0);
|
|
|
+ storageBillStatistics.setRollClubThreeTotalWeight(0.0);
|
|
|
+ storageBillStatistics.setRollOutShippSum(0);
|
|
|
+ storageBillStatistics.setRollOutShippTotalWeight(0.0);
|
|
|
+ return storageBillStatistics;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<DestinationStatisticsDetails> rollClubTwoStatisticsList = new ArrayList<>();
|
|
|
+
|
|
|
+ List<DestinationStatisticsDetails> rollClubThreeStatisticsList = new ArrayList<>();
|
|
|
+
|
|
|
+ List<DestinationStatisticsDetails> rollOutShippStatisticsList = new ArrayList<>();
|
|
|
+
|
|
|
+
|
|
|
+ List<RollClubTwoDetails> rollClubTwoDetailsListAll = new ArrayList<>();
|
|
|
+ List<RollClubThreeDetails> rollClubThreeDetailsListAll = new ArrayList<>();
|
|
|
+ List<RollOutShippDetails> rollOutShippDetailsListAll = new ArrayList<>();
|
|
|
+
|
|
|
+ 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)) {
|
|
|
+ rollClubTwoDetailsListAll.addAll(rollClubTwoDetailsList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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)) {
|
|
|
+ rollClubThreeDetailsListAll.addAll(rollClubThreeDetailsList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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)) {
|
|
|
+ rollOutShippDetailsListAll.addAll(rollOutShippDetailsList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (oConvertUtils.listIsNotEmpty(rollClubTwoDetailsListAll)){
|
|
|
+ List<DestinationStatisticsDetails> currentList1 = rollClubTwoDetailsListAll.stream()
|
|
|
+ .collect(Collectors.groupingBy(RollClubTwoDetails::getSize, Collectors.toList()))
|
|
|
+ .entrySet().stream()
|
|
|
+ .map(entry -> {
|
|
|
+ String size = entry.getKey();
|
|
|
+ List<RollClubTwoDetails> group = entry.getValue();
|
|
|
+ Integer nums = group.size();
|
|
|
+ boolean shouldMultiply = group.stream().anyMatch(detail -> detail.getStackAddr() != null);
|
|
|
+ if (shouldMultiply) {
|
|
|
+ nums = nums * 4;
|
|
|
+ }
|
|
|
+ Double totalBlankOutput = group.stream().mapToDouble(RollClubTwoDetails::getBlankOutput).sum();
|
|
|
+ BigDecimal bd = BigDecimal.valueOf(totalBlankOutput).setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
+ double finalBlankOutput = bd.doubleValue();
|
|
|
+ String ccmNos = group.isEmpty() ? null : group.get(0).getCcmNo();
|
|
|
+ return new DestinationStatisticsDetails(size, nums, finalBlankOutput, ccmNos);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ rollClubTwoStatisticsList.addAll(currentList1);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (oConvertUtils.listIsNotEmpty(rollClubThreeDetailsListAll)){
|
|
|
+ List<DestinationStatisticsDetails> currentList2 = rollClubThreeDetailsListAll.stream()
|
|
|
+ .collect(Collectors.groupingBy(RollClubThreeDetails::getSize, Collectors.toList()))
|
|
|
+ .entrySet().stream()
|
|
|
+ .map(entry -> {
|
|
|
+ String size = entry.getKey();
|
|
|
+ List<RollClubThreeDetails> group = entry.getValue();
|
|
|
+ Integer nums = group.size();
|
|
|
+ boolean shouldMultiply = group.stream().anyMatch(detail -> detail.getStackAddr() != null);
|
|
|
+ if (shouldMultiply) {
|
|
|
+ nums = nums * 4;
|
|
|
+ }
|
|
|
+ Double totalBlankOutput = group.stream().mapToDouble(RollClubThreeDetails::getBlankOutput).sum();
|
|
|
+ BigDecimal bd = BigDecimal.valueOf(totalBlankOutput).setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
+ double finalBlankOutput = bd.doubleValue();
|
|
|
+ String ccmNos = group.isEmpty() ? null : group.get(0).getCcmNo();
|
|
|
+ return new DestinationStatisticsDetails(size, nums, finalBlankOutput, ccmNos);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ rollClubThreeStatisticsList.addAll(currentList2);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (oConvertUtils.listIsNotEmpty(rollOutShippDetailsListAll)){
|
|
|
+ List<DestinationStatisticsDetails> currentList3 = rollOutShippDetailsListAll.stream()
|
|
|
+ .collect(Collectors.groupingBy(RollOutShippDetails::getSize, Collectors.toList()))
|
|
|
+ .entrySet().stream()
|
|
|
+ .map(entry -> {
|
|
|
+ String size = entry.getKey();
|
|
|
+ List<RollOutShippDetails> group = entry.getValue();
|
|
|
+ Integer nums = group.size();
|
|
|
+ boolean shouldMultiply = group.stream().anyMatch(detail -> detail.getStackAddr() != null);
|
|
|
+ if (shouldMultiply) {
|
|
|
+ nums = nums * 4;
|
|
|
+ }
|
|
|
+ Double totalBlankOutput = group.stream().mapToDouble(RollOutShippDetails::getBlankOutput).sum();
|
|
|
+ BigDecimal bd = BigDecimal.valueOf(totalBlankOutput).setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
+ double finalBlankOutput = bd.doubleValue();
|
|
|
+ String ccmNos = group.isEmpty() ? null : group.get(0).getCcmNo();
|
|
|
+ return new DestinationStatisticsDetails(size, nums, finalBlankOutput, ccmNos);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ rollOutShippStatisticsList.addAll(currentList3);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 计算各个列表的数量总和
|
|
|
+ int rollClubTwoSum = calculateIntSum(rollClubTwoStatisticsList);
|
|
|
+ int rollClubThreeSum = calculateIntSum(rollClubThreeStatisticsList);
|
|
|
+ int rollOutShippSum = calculateIntSum(rollOutShippStatisticsList);
|
|
|
+
|
|
|
+ // 计算各个列表的重量总和
|
|
|
+ double rollClubTwoTotalWeight = calculateDoubleSum(rollClubTwoStatisticsList);
|
|
|
+ double rollClubThreeTotalWeight = calculateDoubleSum(rollClubThreeStatisticsList);
|
|
|
+ double rollOutShippTotalWeight = calculateDoubleSum(rollOutShippStatisticsList);
|
|
|
+
|
|
|
+ // 计算装运总数和总重
|
|
|
+ int storageSum = rollClubTwoSum + rollClubThreeSum + rollOutShippSum;
|
|
|
+ double storageTotalWeight = rollClubTwoTotalWeight + rollClubThreeTotalWeight + rollOutShippTotalWeight;
|
|
|
+ // 使用 String.format 方法保留 4 位小数
|
|
|
+ String formattedWeight = String.format("%.4f", storageTotalWeight);
|
|
|
+
|
|
|
+ // 将格式化后的字符串转换回 double 类型
|
|
|
+ storageTotalWeight = Double.parseDouble(formattedWeight);
|
|
|
+
|
|
|
+ storageBillStatistics.setStorageSum(storageSum);
|
|
|
+ storageBillStatistics.setStorageTotalWeight(storageTotalWeight);
|
|
|
+
|
|
|
+ storageBillStatistics.setRollClubTwoSum(rollClubTwoSum);
|
|
|
+ storageBillStatistics.setRollClubThreeSum(rollClubThreeSum);
|
|
|
+ storageBillStatistics.setRollOutShippSum(rollOutShippSum);
|
|
|
+
|
|
|
+ storageBillStatistics.setRollClubTwoTotalWeight(rollClubTwoTotalWeight);
|
|
|
+ storageBillStatistics.setRollClubThreeTotalWeight(rollClubThreeTotalWeight);
|
|
|
+ storageBillStatistics.setRollOutShippTotalWeight(rollOutShippTotalWeight);
|
|
|
+
|
|
|
+
|
|
|
+ storageBillStatistics.setRollClubTwoStatisticsList(rollClubTwoStatisticsList);
|
|
|
+ storageBillStatistics.setRollClubThreeStatisticsList(rollClubThreeStatisticsList);
|
|
|
+ storageBillStatistics.setRollOutShippStatisticsList(rollOutShippStatisticsList);
|
|
|
+
|
|
|
+ return storageBillStatistics;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 计算整数总和的方法
|
|
|
+ private int calculateIntSum(List<DestinationStatisticsDetails> list) {
|
|
|
+ if (list == null) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ return list.stream().mapToInt(DestinationStatisticsDetails::getNums).sum();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 计算双精度浮点数总和的方法
|
|
|
+ private double calculateDoubleSum(List<DestinationStatisticsDetails> list) {
|
|
|
+ if (list == null) {
|
|
|
+ return 0.0;
|
|
|
+ }
|
|
|
+ return list.stream().mapToDouble(DestinationStatisticsDetails::getBlankOutput).sum();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 生成综合唯一编码
|