Procházet zdrojové kódy

新增棒一、高线棒线工作台统计接口

lingpeng.li před 4 měsíci
rodič
revize
00307dd1fe

+ 8 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/rollClubOne/controller/RollClubOneDetailsController.java

@@ -14,6 +14,7 @@ import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.modules.billet.rollClubOne.entity.HotSendRollClubOneDetails;
 import org.jeecg.modules.billet.rollClubOne.entity.RollClubOneDetails;
 import org.jeecg.modules.billet.rollClubOne.service.IRollClubOneDetailsService;
+import org.jeecg.modules.billet.storageBill.vo.RollOnDutyDataVo;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -218,4 +219,11 @@ public class RollClubOneDetailsController extends JeecgController<RollClubOneDet
 		 return Result.OK(rollClubOneDetails);
 	 }
 
+	@ApiOperation(value = "轧钢棒一工作台信息", notes = "轧钢棒一工作台信息")
+	@GetMapping(value = "/rollClubOneWorkbenches")
+	public Result<RollOnDutyDataVo> rollClubOneWorkbenches(@RequestParam(name = "ccmNo") String ccmNo) {
+
+		RollOnDutyDataVo rollOnDutyVo = rollClubOneDetailsService.queryOnDutyRecord(ccmNo);
+		return Result.OK(rollOnDutyVo);
+	}
 }

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

@@ -2,6 +2,7 @@ package org.jeecg.modules.billet.rollClubOne.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.billet.rollClubOne.entity.RollClubOneDetails;
+import org.jeecg.modules.billet.storageBill.vo.RollOnDutyDataVo;
 
 /**
  * @Description: 棒一明细信息
@@ -11,4 +12,5 @@ import org.jeecg.modules.billet.rollClubOne.entity.RollClubOneDetails;
  */
 public interface IRollClubOneDetailsService extends IService<RollClubOneDetails> {
 
+    RollOnDutyDataVo queryOnDutyRecord(String ccmNo);
 }

+ 113 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/rollClubOne/service/impl/RollClubOneDetailsServiceImpl.java

@@ -1,18 +1,131 @@
 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 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.mapper.RollClubOneDetailsMapper;
 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 java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
+
 /**
  * @Description: 棒一明细信息
  * @Author: jeecg-boot
  * @Date:   2024-11-20
  * @Version: V1.0
  */
+
+@Slf4j
 @Service
 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));
+    }
 }

+ 0 - 1
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/rollClubThree/service/impl/RollClubThreeDetailsServiceImpl.java

@@ -58,7 +58,6 @@ public class RollClubThreeDetailsServiceImpl extends ServiceImpl<RollClubThreeDe
         queryWrapper.eq(BilletHotsendChangeShift::getCcmNo, ccmNo)
                 .eq(BilletHotsendChangeShift::getShift, shift)
                 .eq(BilletHotsendChangeShift::getShiftGroup, shiftGroup)
-                .isNull(BilletHotsendChangeShift::getChangeShiftTime)
                 .orderByDesc(BilletHotsendChangeShift::getCreateTime)
                 .last("limit 1");
 

+ 0 - 1
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/rollClubTwo/service/impl/RollClubTwoDetailsServiceImpl.java

@@ -57,7 +57,6 @@ public class RollClubTwoDetailsServiceImpl extends ServiceImpl<RollClubTwoDetail
         queryWrapper.eq(BilletHotsendChangeShift::getCcmNo, ccmNo)
                 .eq(BilletHotsendChangeShift::getShift, shift)
                 .eq(BilletHotsendChangeShift::getShiftGroup, shiftGroup)
-                .isNull(BilletHotsendChangeShift::getChangeShiftTime)
                 .orderByDesc(BilletHotsendChangeShift::getCreateTime)
                 .last("limit 1");
 

+ 9 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/rollHeight/controller/RollHeightDetailsController.java

@@ -14,6 +14,7 @@ import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.modules.billet.rollHeight.entity.HotSendRollHeightDetails;
 import org.jeecg.modules.billet.rollHeight.entity.RollHeightDetails;
 import org.jeecg.modules.billet.rollHeight.service.IRollHeightDetailsService;
+import org.jeecg.modules.billet.storageBill.vo.RollOnDutyDataVo;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -219,4 +220,12 @@ public class RollHeightDetailsController extends JeecgController<RollHeightDetai
 		List<RollHeightDetails> rollHeightDetailsList = rollHeightDetailsService.list(queryWrapper);
 		return Result.OK(rollHeightDetailsList);
 	}
+
+	@ApiOperation(value = "轧钢高线工作台信息", notes = "轧钢高线工作台信息")
+	@GetMapping(value = "/rollHeightWorkbenches")
+	public Result<RollOnDutyDataVo> rollHeightWorkbenches(@RequestParam(name = "ccmNo") String ccmNo) {
+
+		RollOnDutyDataVo rollOnDutyVo = rollHeightDetailsService.queryOnDutyRecord(ccmNo);
+		return Result.OK(rollOnDutyVo);
+	}
 }

+ 3 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/rollHeight/service/IRollHeightDetailsService.java

@@ -2,6 +2,7 @@ package org.jeecg.modules.billet.rollHeight.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.billet.rollHeight.entity.RollHeightDetails;
+import org.jeecg.modules.billet.storageBill.vo.RollOnDutyDataVo;
 
 /**
  * @Description: 高线明细信息
@@ -11,4 +12,6 @@ import org.jeecg.modules.billet.rollHeight.entity.RollHeightDetails;
  */
 public interface IRollHeightDetailsService extends IService<RollHeightDetails> {
 
+    RollOnDutyDataVo queryOnDutyRecord(String ccmNo);
+
 }

+ 114 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/rollHeight/service/impl/RollHeightDetailsServiceImpl.java

@@ -1,18 +1,132 @@
 package org.jeecg.modules.billet.rollHeight.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 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.rollClubThree.entity.RollClubThreeDetails;
 import org.jeecg.modules.billet.rollHeight.entity.RollHeightDetails;
 import org.jeecg.modules.billet.rollHeight.mapper.RollHeightDetailsMapper;
 import org.jeecg.modules.billet.rollHeight.service.IRollHeightDetailsService;
+import org.jeecg.modules.billet.storageBill.entity.StorageBill;
+import org.jeecg.modules.billet.storageBill.mapper.StorageBillMapper;
+import org.jeecg.modules.billet.storageBill.vo.*;
+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 java.math.BigDecimal;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
+
 /**
  * @Description: 高线明细信息
  * @Author: jeecg-boot
  * @Date:   2024-11-20
  * @Version: V1.0
  */
+
+@Slf4j
 @Service
 public class RollHeightDetailsServiceImpl extends ServiceImpl<RollHeightDetailsMapper, RollHeightDetails> implements IRollHeightDetailsService {
 
+    @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<RollHeightDetails> infoQueryWrapper = new LambdaQueryWrapper<>();
+        infoQueryWrapper.eq(RollHeightDetails::getCcmNo, ccmNo)
+                .eq(RollHeightDetails::getShift, shift)
+                .eq(RollHeightDetails::getShiftGroup, shiftGroup)
+                .between(RollHeightDetails::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<RollHeightDetails> historyQueryWrapper = new LambdaQueryWrapper<>();
+        historyQueryWrapper.eq(RollHeightDetails::getCcmNo, ccmNo);
+
+        List<RollHeightDetails> rollHeightHistoryDetailsList = baseMapper.selectList(historyQueryWrapper);
+        List<RollHistoryDetailVo> historyDetailList = rollHeightHistoryDetailsList.stream()
+                .collect(Collectors.groupingBy(RollHeightDetails::getSize))
+                .entrySet().stream()
+                .map(entry -> {
+                    String size = entry.getKey();
+                    List<RollHeightDetails> detailsList = entry.getValue();
+
+                    int totalCount = detailsList.stream()
+                            .mapToInt(detail -> (detail.getStackAddr() == null || detail.getStackAddr().isEmpty()) ? 1 : 4)
+                            .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));
+    }
+
 }

+ 0 - 1
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/rollOutShipp/service/impl/RollOutShippDetailsServiceImpl.java

@@ -57,7 +57,6 @@ public class RollOutShippDetailsServiceImpl extends ServiceImpl<RollOutShippDeta
         queryWrapper.eq(BilletHotsendChangeShift::getCcmNo, ccmNo)
                 .eq(BilletHotsendChangeShift::getShift, shift)
                 .eq(BilletHotsendChangeShift::getShiftGroup, shiftGroup)
-                .isNull(BilletHotsendChangeShift::getChangeShiftTime)
                 .orderByDesc(BilletHotsendChangeShift::getCreateTime)
                 .last("limit 1");