|
@@ -1,18 +1,131 @@
|
|
package org.jeecg.modules.billet.rollClubOne.service.impl;
|
|
package org.jeecg.modules.billet.rollClubOne.service.impl;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.jeecg.common.util.oConvertUtils;
|
|
|
|
+import org.jeecg.modules.billet.billetHotsendChangeShift.entity.BilletHotsendChangeShift;
|
|
|
|
+import org.jeecg.modules.billet.billetHotsendChangeShift.service.IBilletHotsendChangeShiftService;
|
|
import org.jeecg.modules.billet.rollClubOne.entity.RollClubOneDetails;
|
|
import org.jeecg.modules.billet.rollClubOne.entity.RollClubOneDetails;
|
|
import org.jeecg.modules.billet.rollClubOne.mapper.RollClubOneDetailsMapper;
|
|
import org.jeecg.modules.billet.rollClubOne.mapper.RollClubOneDetailsMapper;
|
|
import org.jeecg.modules.billet.rollClubOne.service.IRollClubOneDetailsService;
|
|
import org.jeecg.modules.billet.rollClubOne.service.IRollClubOneDetailsService;
|
|
|
|
+import org.jeecg.modules.billet.rollHeight.entity.RollHeightDetails;
|
|
|
|
+import org.jeecg.modules.billet.storageBill.mapper.StorageBillMapper;
|
|
|
|
+import org.jeecg.modules.billet.storageBill.vo.RollHistoryDetailVo;
|
|
|
|
+import org.jeecg.modules.billet.storageBill.vo.RollOnDutyDataVo;
|
|
|
|
+import org.jeecg.modules.billet.storageBill.vo.RollOnDutyInfoVo;
|
|
|
|
+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.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @Description: 棒一明细信息
|
|
* @Description: 棒一明细信息
|
|
* @Author: jeecg-boot
|
|
* @Author: jeecg-boot
|
|
* @Date: 2024-11-20
|
|
* @Date: 2024-11-20
|
|
* @Version: V1.0
|
|
* @Version: V1.0
|
|
*/
|
|
*/
|
|
|
|
+
|
|
|
|
+@Slf4j
|
|
@Service
|
|
@Service
|
|
public class RollClubOneDetailsServiceImpl extends ServiceImpl<RollClubOneDetailsMapper, RollClubOneDetails> implements IRollClubOneDetailsService {
|
|
public class RollClubOneDetailsServiceImpl extends ServiceImpl<RollClubOneDetailsMapper, RollClubOneDetails> implements IRollClubOneDetailsService {
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IBilletHotsendChangeShiftService billetHotsendChangeShiftService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ public RedisTemplate redisTemplate;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private StorageBillMapper storageBillMapper;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public RollOnDutyDataVo queryOnDutyRecord(String ccmNo) {
|
|
|
|
+ RollOnDutyDataVo rollOnDutyVo = new RollOnDutyDataVo();
|
|
|
|
+
|
|
|
|
+ // 从 Redis 获取班次信息
|
|
|
|
+ String shiftGroup = getShiftInfo(ccmNo, "class:shift:group:%s");
|
|
|
|
+ String 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 billetHotsendChangeShift = billetHotsendChangeShiftService.getOne(queryWrapper);
|
|
|
|
+ if (billetHotsendChangeShift == null) {
|
|
|
|
+ log.info("{}{}", "查询当班装运单信息失败,交班记录为空!", ccmNo + "失败时间:" + new Date());
|
|
|
|
+ return rollOnDutyVo;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 查询 Info 数据
|
|
|
|
+ LambdaQueryWrapper<RollClubOneDetails> infoQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ infoQueryWrapper.eq(RollClubOneDetails::getCcmNo, ccmNo)
|
|
|
|
+ .eq(RollClubOneDetails::getShift, shift)
|
|
|
|
+ .eq(RollClubOneDetails::getShiftGroup, shiftGroup)
|
|
|
|
+ .between(RollClubOneDetails::getCreateTime, billetHotsendChangeShift.getCreateTime(), new Date());
|
|
|
|
+
|
|
|
|
+ List<RollOnDutyInfoVo> infoVoList = baseMapper.selectList(infoQueryWrapper).stream()
|
|
|
|
+ .map(details -> {
|
|
|
|
+ RollOnDutyInfoVo infoVo = new RollOnDutyInfoVo();
|
|
|
|
+ BeanUtils.copyProperties(details, infoVo);
|
|
|
|
+ return infoVo;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ // 计算历史数据统计
|
|
|
|
+ LambdaQueryWrapper<RollClubOneDetails> historyQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ historyQueryWrapper.eq(RollClubOneDetails::getCcmNo, ccmNo);
|
|
|
|
+
|
|
|
|
+ List<RollClubOneDetails> rollHeightHistoryDetailsList = baseMapper.selectList(historyQueryWrapper);
|
|
|
|
+ List<RollHistoryDetailVo> historyDetailList = rollHeightHistoryDetailsList.stream()
|
|
|
|
+ .collect(Collectors.groupingBy(RollClubOneDetails::getSize))
|
|
|
|
+ .entrySet().stream()
|
|
|
|
+ .map(entry -> {
|
|
|
|
+ String size = entry.getKey();
|
|
|
|
+ List<RollClubOneDetails> detailsList = entry.getValue();
|
|
|
|
+
|
|
|
|
+ int totalCount = detailsList.stream()
|
|
|
|
+ .mapToInt(detail -> 1) // 直接给 1
|
|
|
|
+ .sum();
|
|
|
|
+
|
|
|
|
+ BigDecimal totalBlankOutput = detailsList.stream()
|
|
|
|
+ .map(detail -> BigDecimal.valueOf(detail.getBlankOutput()))
|
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add)
|
|
|
|
+ .setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+
|
|
|
|
+ RollHistoryDetailVo rollHistoryDetailVo = new RollHistoryDetailVo();
|
|
|
|
+ rollHistoryDetailVo.setSize(size);
|
|
|
|
+ rollHistoryDetailVo.setAmountTotal(totalCount);
|
|
|
|
+ rollHistoryDetailVo.setBlankOutput(totalBlankOutput);
|
|
|
|
+ return rollHistoryDetailVo;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ // 组装最终对象
|
|
|
|
+ rollOnDutyVo.setRollOnDutyInfoList(infoVoList);
|
|
|
|
+ rollOnDutyVo.setRollHistoryDetailList(historyDetailList);
|
|
|
|
+
|
|
|
|
+ return rollOnDutyVo;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 从Redis中获取班组班别
|
|
|
|
+ *
|
|
|
|
+ * @param ccmNo
|
|
|
|
+ * @param keyFormat
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private String getShiftInfo(String ccmNo, String keyFormat) {
|
|
|
|
+ String key = String.format(keyFormat, ccmNo);
|
|
|
|
+ return oConvertUtils.getString(redisTemplate.opsForValue().get(key));
|
|
|
|
+ }
|
|
}
|
|
}
|