|
@@ -9,6 +9,7 @@ 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;
|
|
@@ -238,6 +239,61 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public BilletHotsendDetails findBilletHotChargingDetails(StorageBill storageBill) {
|
|
|
+ BilletHotsendDetails result = new BilletHotsendDetails();
|
|
|
+
|
|
|
+ List<String> idList = Arrays.stream(storageBill.getId().split(","))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (oConvertUtils.listIsEmpty(idList)){
|
|
|
+ log.info("{}{}", "装运单ID为空,装运明细查询失败", JSON.toJSON(storageBill));
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> typeConfigIds = Arrays.stream(storageBill.getTypeConfigId().split(","))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (oConvertUtils.listIsEmpty(typeConfigIds)){
|
|
|
+ log.info("{}{}", "钢坯配置类型ID为空,装运明细查询失败", JSON.toJSON(storageBill));
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据部门orgCode查询部门,需要将职位id进行传递
|
|
|
+ List<BilletHotsendTypeConfig> billetHotsendTypeConfigs = billetHotsendTypeConfigService.listByIds(typeConfigIds);
|
|
|
+ if (CollectionUtils.isEmpty(billetHotsendTypeConfigs)){
|
|
|
+ log.info("{}{}", "钢坯类型配置信息查询为空,装运明细查询失败", JSON.toJSON(storageBill));
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ for (BilletHotsendTypeConfig billetHotsendTypeConfig : billetHotsendTypeConfigs) {
|
|
|
+ if ("billet_auto_tmp".equals(billetHotsendTypeConfig.getBelongTable())){
|
|
|
+ List<BilletAutoTmp> billetAutoTmpList = billetAutoTmpService.list(new LambdaQueryWrapper<BilletAutoTmp>().in(BilletAutoTmp::getStorageBillId, idList));
|
|
|
+ if (oConvertUtils.listIsNotEmpty(billetAutoTmpList)){
|
|
|
+ List<RollClubTwoDetails> rollClubTwoDetailsList = new ArrayList<>();
|
|
|
+ billetAutoTmpList.forEach(x ->{
|
|
|
+ RollClubTwoDetails rollClubTwoDetails = new RollClubTwoDetails();
|
|
|
+ BeanUtils.copyProperties(x, rollClubTwoDetails);
|
|
|
+ rollClubTwoDetailsList.add(rollClubTwoDetails);
|
|
|
+ });
|
|
|
+ result.setRollClubTwoDetailsList(rollClubTwoDetailsList);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<RollClubOneDetails> rollClubOneDetailsList = rollClubOneDetailsService.list(new LambdaQueryWrapper<RollClubOneDetails>().in(RollClubOneDetails::getStorageBillId, idList));
|
|
|
+ result.setRollClubOneDetailsList(rollClubOneDetailsList);
|
|
|
+ List<RollClubTwoDetails> rollClubTwoDetailsList = rollClubTwoDetailsService.list(new LambdaQueryWrapper<RollClubTwoDetails>().in(RollClubTwoDetails::getStorageBillId, idList));
|
|
|
+ result.setRollClubTwoDetailsList(rollClubTwoDetailsList);
|
|
|
+ List<RollClubThreeDetails> rollClubThreeDetailsList = rollClubThreeDetailsService.list(new LambdaQueryWrapper<RollClubThreeDetails>().in(RollClubThreeDetails::getStorageBillId, idList));
|
|
|
+ result.setRollClubThreeDetailsList(rollClubThreeDetailsList);
|
|
|
+ List<RollOutShippDetails> rollOutShippDetailsList = rollOutShippDetailsService.list(new LambdaQueryWrapper<RollOutShippDetails>().in(RollOutShippDetails::getStorageBillId, idList));
|
|
|
+ result.setRollOutShippDetailsList(rollOutShippDetailsList);
|
|
|
+ List<RollHeightDetails> rollHeightDetails = rollHeightDetailsService.list(new LambdaQueryWrapper<RollHeightDetails>().in(RollHeightDetails::getStorageBillId, idList));
|
|
|
+ result.setRollHeightDetails(rollHeightDetails);
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<StorageBill> findCar(String ccmNo, String destination) {
|
|
|
return storageBillMapper.findCar(ccmNo, destination);
|
|
@@ -683,6 +739,156 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
|
|
|
return onDutyStatistics;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public OnDutyStatistics queryHotChargingStatistics(String ccmNo) {
|
|
|
+ OnDutyStatistics onDutyStatistics = new OnDutyStatistics();
|
|
|
+
|
|
|
+ // 获取当前班组班次信息
|
|
|
+ String keyShiftGroup = String.format("class:shift:group:%s", ccmNo);
|
|
|
+ String keyShift = String.format("class:shift:%s", ccmNo);
|
|
|
+ String shiftGroup = oConvertUtils.getString(redisTemplate.opsForValue().get(keyShiftGroup));
|
|
|
+ String shift = oConvertUtils.getString(redisTemplate.opsForValue().get(keyShift));
|
|
|
+ if (oConvertUtils.isEmpty(shiftGroup) || oConvertUtils.isEmpty(shift)){
|
|
|
+ log.info("{}{}", "B端热装单统计当班热装查询失败!", "未查询到当班信息!");
|
|
|
+ return onDutyStatistics;
|
|
|
+ }
|
|
|
+ // 根据铸机号、班组班别查询对应的热送单信息
|
|
|
+ BilletHotsendChangeShift billetHotsendChangeShiftList = billetHotsendChangeShiftService.getOne(new LambdaQueryWrapper<BilletHotsendChangeShift>()
|
|
|
+ .eq(BilletHotsendChangeShift::getCcmNo, ccmNo).eq(BilletHotsendChangeShift::getShiftGroup, shiftGroup).eq(BilletHotsendChangeShift::getShift, shift)
|
|
|
+ .orderByDesc(BilletHotsendChangeShift::getCreateTime).last("limit 1"));
|
|
|
+ // 查询热装信息(棒二明细、棒三明细、上若明细)统计热装总支数、热装总重量<出坯量>
|
|
|
+ List<DestinationStatisticsDetails> statisticsDetailsList1 = new ArrayList<>();
|
|
|
+ List<DestinationStatisticsDetails> statisticsDetailsList2 = new ArrayList<>();
|
|
|
+ List<DestinationStatisticsDetails> statisticsDetailsList3 = new ArrayList<>();
|
|
|
+ // 统计总数
|
|
|
+ int totalNumsAll = 0;
|
|
|
+ BigDecimal totalBlankOutputsAll = BigDecimal.ZERO;
|
|
|
+ LambdaQueryWrapper<RollClubTwoDetails> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(RollClubTwoDetails::getCcmNo, ccmNo);
|
|
|
+ queryWrapper.eq(RollClubTwoDetails::getShiftGroup, shiftGroup);
|
|
|
+ queryWrapper.eq(RollClubTwoDetails::getShift, shift);
|
|
|
+ // 添加大于 billetHotsendChangeShiftList 的 createTime 条件
|
|
|
+ if (billetHotsendChangeShiftList != null && billetHotsendChangeShiftList.getCreateTime() != null) {
|
|
|
+ queryWrapper.gt(RollClubTwoDetails::getCreateTime, billetHotsendChangeShiftList.getCreateTime());
|
|
|
+ }
|
|
|
+ List<RollClubTwoDetails> rollClubTwoDetailsList = rollClubTwoDetailsService.list(queryWrapper);
|
|
|
+ if (oConvertUtils.listIsNotEmpty(rollClubTwoDetailsList)){
|
|
|
+ statisticsDetailsList1 = rollClubTwoDetailsList.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();
|
|
|
+ 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());
|
|
|
+ int totalNums = statisticsDetailsList1.stream()
|
|
|
+ .mapToInt(DestinationStatisticsDetails::getNums)
|
|
|
+ .sum();
|
|
|
+
|
|
|
+ double totalBlankOutputs = rollClubTwoDetailsList.stream().mapToDouble(RollClubTwoDetails::getBlankOutput).sum();
|
|
|
+ BigDecimal bd = BigDecimal.valueOf(totalBlankOutputs).setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
+ totalNumsAll += totalNums;
|
|
|
+ totalBlankOutputsAll = totalBlankOutputsAll.add(bd);
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaQueryWrapper<RollClubThreeDetails> queryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper1.eq(RollClubThreeDetails::getCcmNo, ccmNo);
|
|
|
+ queryWrapper1.eq(RollClubThreeDetails::getShiftGroup, shiftGroup);
|
|
|
+ queryWrapper1.eq(RollClubThreeDetails::getShift, shift);
|
|
|
+ // 添加大于 billetHotsendChangeShiftList 的 createTime 条件
|
|
|
+ if (billetHotsendChangeShiftList != null && billetHotsendChangeShiftList.getCreateTime() != null) {
|
|
|
+ queryWrapper1.gt(RollClubThreeDetails::getCreateTime, billetHotsendChangeShiftList.getCreateTime());
|
|
|
+ }
|
|
|
+ List<RollClubThreeDetails> rollClubThreeDetailsList = rollClubThreeDetailsService.list(queryWrapper1);
|
|
|
+ if (oConvertUtils.listIsNotEmpty(rollClubThreeDetailsList)){
|
|
|
+ statisticsDetailsList2 = rollClubThreeDetailsList.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();
|
|
|
+ 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());
|
|
|
+ int totalNums = statisticsDetailsList2.stream()
|
|
|
+ .mapToInt(DestinationStatisticsDetails::getNums)
|
|
|
+ .sum();
|
|
|
+
|
|
|
+ double totalBlankOutputs = rollClubThreeDetailsList.stream().mapToDouble(RollClubThreeDetails::getBlankOutput).sum();
|
|
|
+ BigDecimal bd = BigDecimal.valueOf(totalBlankOutputs).setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
+
|
|
|
+ totalNumsAll += totalNums;
|
|
|
+ totalBlankOutputsAll = totalBlankOutputsAll.add(bd);
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaQueryWrapper<RollOutShippDetails> queryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper2.eq(RollOutShippDetails::getCcmNo, ccmNo);
|
|
|
+ queryWrapper2.eq(RollOutShippDetails::getShiftGroup, shiftGroup);
|
|
|
+ queryWrapper2.eq(RollOutShippDetails::getShift, shift);
|
|
|
+ // 添加大于 billetHotsendChangeShiftList 的 createTime 条件
|
|
|
+ if (billetHotsendChangeShiftList != null && billetHotsendChangeShiftList.getCreateTime() != null) {
|
|
|
+ queryWrapper2.gt(RollOutShippDetails::getCreateTime, billetHotsendChangeShiftList.getCreateTime());
|
|
|
+ }
|
|
|
+ List<RollOutShippDetails> rollOutShippDetailsList = rollOutShippDetailsService.list(queryWrapper2);
|
|
|
+ if (oConvertUtils.listIsNotEmpty(rollOutShippDetailsList)){
|
|
|
+ statisticsDetailsList3 = rollOutShippDetailsList.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();
|
|
|
+ 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());
|
|
|
+ int totalNums = statisticsDetailsList3.stream()
|
|
|
+ .mapToInt(DestinationStatisticsDetails::getNums)
|
|
|
+ .sum();
|
|
|
+
|
|
|
+ double totalBlankOutputs = rollOutShippDetailsList.stream().mapToDouble(RollOutShippDetails::getBlankOutput).sum();
|
|
|
+ BigDecimal bd = BigDecimal.valueOf(totalBlankOutputs).setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
+
|
|
|
+ totalNumsAll += totalNums;
|
|
|
+ totalBlankOutputsAll = totalBlankOutputsAll.add(bd);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 合并三个列表并根据 size 分组统计
|
|
|
+ List<DestinationStatisticsDetails> mergedList = Stream.of(statisticsDetailsList1, statisticsDetailsList2, statisticsDetailsList3)
|
|
|
+ .flatMap(Collection::stream) // 将所有列表合并成一个流
|
|
|
+ .collect(Collectors.groupingBy(DestinationStatisticsDetails::getSize))
|
|
|
+ .entrySet().stream()
|
|
|
+ .map(entry -> {
|
|
|
+ String size = entry.getKey();
|
|
|
+ List<DestinationStatisticsDetails> group = entry.getValue();
|
|
|
+ int totalNums = group.stream().mapToInt(DestinationStatisticsDetails::getNums).sum();
|
|
|
+ double totalBlankOutput = group.stream().mapToDouble(DestinationStatisticsDetails::getBlankOutput).sum();
|
|
|
+ BigDecimal bd = BigDecimal.valueOf(totalBlankOutput).setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
+ double finalBlankOutput = bd.doubleValue();
|
|
|
+ String ccmNoForGroup = group.isEmpty() ? null : group.get(0).getCcmNo();
|
|
|
+ return new DestinationStatisticsDetails(size, totalNums, finalBlankOutput, ccmNoForGroup);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ log.info("{}{}", "钢坯热装单班统计查询结果:", JSON.toJSON(mergedList));
|
|
|
+ onDutyStatistics.setCounts(totalNumsAll);
|
|
|
+ onDutyStatistics.setBlankOutputs(totalBlankOutputsAll);
|
|
|
+ onDutyStatistics.setStatisticsDetailsList(mergedList);
|
|
|
+ onDutyStatistics.setShiftGroup(ShiftGroupEnum.fromCode(shiftGroup).name());
|
|
|
+ onDutyStatistics.setShift(ShiftEnum.fromCode(shift).name());
|
|
|
+ return onDutyStatistics;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public JSONObject ondutyStatisticsExport(String ccmNo, String ondutyDate) {
|
|
|
JSONObject result = new JSONObject();
|