Browse Source

管控中心查询接口新增

qiangxuan 1 day ago
parent
commit
60dadd58f9

+ 188 - 1
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/storageBill/controller/StorageBillPrintController.java

@@ -37,6 +37,7 @@ import org.jeecg.modules.billet.rollOutShipp.entity.RollOutShippDetails;
 import org.jeecg.modules.billet.rollOutShipp.service.IRollOutShippDetailsService;
 import org.jeecg.modules.billet.storageBill.entity.StorageBill;
 import org.jeecg.modules.billet.storageBill.entity.StorageBillPrint;
+import org.jeecg.modules.billet.storageBill.entity.StorageBilletControl;
 import org.jeecg.modules.billet.storageBill.service.IStorageBillPrintService;
 import org.jeecg.modules.billet.storageBill.service.IStorageBillService;
 import org.jeecg.modules.billet.storageBill.vo.StorageCenterExportRow;
@@ -47,6 +48,7 @@ import org.jeecg.modules.carUnit.service.ISysDictItemService;
 import org.jeecg.modules.carUnit.service.ISysDictService;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
@@ -56,6 +58,8 @@ import java.math.RoundingMode;
 import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
 import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * @Description: 装运单打印表
@@ -96,7 +100,8 @@ public class StorageBillPrintController extends JeecgController<StorageBillPrint
     BilletRulerConfigMapper billetRulerConfigMapper;
     @Autowired
     private ISysDictService sysDictService;
-
+    @Autowired
+    public RedisTemplate redisTemplate;
     /**
      * 分页列表查询
      *
@@ -615,5 +620,187 @@ public class StorageBillPrintController extends JeecgController<StorageBillPrint
         }
     }
 
+    @ApiOperation(value = "储运中心钢坯运输管控平台", notes = "储运中心钢坯运输管控平台")
+    @GetMapping(value = "/queryStorageBilletControl")
+    public Result<StorageBilletControl> queryByStorageBillPrint() {
+        StorageBilletControl storageBilletControl = new StorageBilletControl();
+        List<StorageBillPrint> storageBillPrintAllList = new ArrayList<>();
+
+        List<Map<String, Object>> fiveSbInfoList = new ArrayList<>();
+        String classShift5 = String.format("class:shift:%s", "5"); // 班别
+        String classShiftGroup5 = String.format("class:shift:group:%s", "5"); // 班组
+        // 从 Redis 获取默认值
+        String shift5 = !oConvertUtils.getString(redisTemplate.opsForValue().get(classShift5)).isEmpty()
+                ? oConvertUtils.getString(redisTemplate.opsForValue().get(classShift5)) : "";
+        String shiftGroup5 = !oConvertUtils.getString(redisTemplate.opsForValue().get(classShiftGroup5)).isEmpty()
+                ? oConvertUtils.getString(redisTemplate.opsForValue().get(classShiftGroup5)) : "";
+
+        BilletHotsendChangeShift billetHotsendChangeShift = handleBilletHotsendChangeShift("5", shift5, shiftGroup5);
+        if (billetHotsendChangeShift == null) {
+            return Result.error("未找到对应班次数据");
+        }
+        String classes5 = shift5 + "/" + shiftGroup5;
+        List<StorageBillPrint> storageBillPrintFiveList = handleStorageBillPrint("5", classes5, billetHotsendChangeShift.getCreateTime());
+        if (oConvertUtils.listIsNotEmpty(storageBillPrintFiveList)){
+            int billetSum5 = storageBillPrintFiveList.stream().mapToInt(StorageBillPrint::getAmountTotal).sum();
+            Map<String, Object> fiveSbInfo = new HashMap<>();
+            fiveSbInfo.put("carSum", storageBillPrintFiveList.size()); // 总车次
+            fiveSbInfo.put("billetSum", billetSum5); // 总支数
+            fiveSbInfo.put("shift5", shift5); // 班组
+            fiveSbInfo.put("shiftGroup5", shiftGroup5); // 班别
+
+            fiveSbInfo.put("steelRollingSum", billetSum5); // 轧钢接收总数
+            fiveSbInfo.put("hotChargeSum", billetSum5); // 热装支数
+
+            //从storageBillPrintFiveList 过滤出btype = 0 并且 destination = 棒二 的车次数总和
+            List<StorageBillPrint> storageBillPrintFiveListBtype0 = storageBillPrintFiveList.stream()
+                    .filter(storageBillPrint -> storageBillPrint.getBtype().equals("0") && storageBillPrint.getDestination().equals("棒二"))
+                    .collect(Collectors.toList());
+            fiveSbInfo.put("hRollClubTwoCarSum", storageBillPrintFiveListBtype0.size()); //热 棒二车次数
+            fiveSbInfo.put("hRollClubTwoSum", storageBillPrintFiveListBtype0.stream().mapToInt(StorageBillPrint::getAmountTotal).sum()); //热 棒二接收数
+
+            List<StorageBillPrint> storageBillPrintFiveListBtype1 = storageBillPrintFiveList.stream()
+                    .filter(storageBillPrint -> storageBillPrint.getBtype().equals("0") && storageBillPrint.getDestination().equals("棒三"))
+                    .collect(Collectors.toList());
+            fiveSbInfo.put("hRollClubThreeCarSum", storageBillPrintFiveListBtype1.size()); //热 棒三车次数
+            fiveSbInfo.put("hRollClubThreeSum", storageBillPrintFiveListBtype1.stream().mapToInt(StorageBillPrint::getAmountTotal).sum()); //热 棒三接收数
+
+            List<StorageBillPrint> storageBillPrintFiveListBtype2 = storageBillPrintFiveList.stream()
+                    .filter(storageBillPrint -> storageBillPrint.getBtype().equals("0") && storageBillPrint.getDestination().equals("上若"))
+                    .collect(Collectors.toList());
+            fiveSbInfo.put("hRollOutShippCarSum", storageBillPrintFiveListBtype2.size()); //热 上若车次数
+            fiveSbInfo.put("hRollOutShippSum", storageBillPrintFiveListBtype2.stream().mapToInt(StorageBillPrint::getAmountTotal).sum()); //热 上若接收数
+
+            List<StorageBillPrint> storageBillPrintFiveColdList1 = storageBillPrintFiveList.stream()
+                    .filter(storageBillPrint -> storageBillPrint.getBtype().equals("1") && storageBillPrint.getDestination().equals("棒二"))
+                    .collect(Collectors.toList());
+            fiveSbInfo.put("cRollClubTwoCarSum", storageBillPrintFiveColdList1.size()); //冷 棒二车次数
+            fiveSbInfo.put("cRollClubTwoSum", storageBillPrintFiveColdList1.stream().mapToInt(StorageBillPrint::getAmountTotal).sum()); //冷 棒二接收数
+
+
+            List<StorageBillPrint> storageBillPrintFiveColdList2 = storageBillPrintFiveList.stream()
+                    .filter(storageBillPrint -> storageBillPrint.getBtype().equals("1") && storageBillPrint.getDestination().equals("棒三"))
+                    .collect(Collectors.toList());
+            fiveSbInfo.put("cRollClubThreeCarSum", storageBillPrintFiveColdList2.size()); //冷 棒三车次数
+            fiveSbInfo.put("cRollClubThreeSum", storageBillPrintFiveColdList2.stream().mapToInt(StorageBillPrint::getAmountTotal).sum()); //冷 棒三接收数
+
+
+            List<StorageBillPrint> storageBillPrintFiveColdList3 = storageBillPrintFiveList.stream()
+                    .filter(storageBillPrint -> storageBillPrint.getBtype().equals("1") && storageBillPrint.getDestination().equals("上若"))
+                    .collect(Collectors.toList());
+            fiveSbInfo.put("cRollOutShippCarSum", storageBillPrintFiveColdList3.size()); //冷 上若车次数
+            fiveSbInfo.put("cRollOutShippSum", storageBillPrintFiveColdList3.stream().mapToInt(StorageBillPrint::getAmountTotal).sum()); //冷 上若接收数
+            fiveSbInfoList.add(fiveSbInfo);
+            storageBilletControl.setFiveSbInfoList(fiveSbInfoList);
+        }
+
+
+        List<Map<String, Object>> sixSbInfoList = new ArrayList<>();
+
+        String classShift6 = String.format("class:shift:%s", "6"); // 班别
+        String classShiftGroup6 = String.format("class:shift:group:%s", "6"); // 班组
+        // 从 Redis 获取默认值
+        String shift6 = !oConvertUtils.getString(redisTemplate.opsForValue().get(classShift6)).isEmpty()
+                ? oConvertUtils.getString(redisTemplate.opsForValue().get(classShift6)) : "";
+        String shiftGroup6 = !oConvertUtils.getString(redisTemplate.opsForValue().get(classShiftGroup6)).isEmpty()
+                ? oConvertUtils.getString(redisTemplate.opsForValue().get(classShiftGroup6)) : "";
+
+        BilletHotsendChangeShift billetHotsendChangeShiftInfo = handleBilletHotsendChangeShift("6", shift6, shiftGroup6);
+        if (billetHotsendChangeShiftInfo == null) {
+            return Result.error("未找到对应6#班次数据");
+        }
+        String classes6 = shift6 + "/" + shiftGroup6;
+        List<StorageBillPrint> storageBillPrintSixList = handleStorageBillPrint("6", classes6, billetHotsendChangeShift.getCreateTime());
+        if (oConvertUtils.listIsNotEmpty(storageBillPrintSixList)){
+            int billetSum6 = storageBillPrintSixList.stream().mapToInt(StorageBillPrint::getAmountTotal).sum();
+            Map<String, Object> fiveSbInfo = new HashMap<>();
+            fiveSbInfo.put("carSum", storageBillPrintSixList.size()); // 总车次
+            fiveSbInfo.put("billetSum", billetSum6); // 总支数
+            fiveSbInfo.put("shift6", shift6); // 班组
+            fiveSbInfo.put("shiftGroup6", shiftGroup6); // 班别
+
+            fiveSbInfo.put("steelRollingSum", billetSum6); // 轧钢接收总数
+            fiveSbInfo.put("hotChargeSum", billetSum6); // 热装支数
+
+            //从storageBillPrintFiveList 过滤出btype = 0 并且 destination = 棒二 的车次数总和
+            List<StorageBillPrint> storageBillPrintSixListBtype0 = storageBillPrintSixList.stream()
+                    .filter(storageBillPrint -> storageBillPrint.getBtype().equals("0") && storageBillPrint.getDestination().equals("棒二"))
+                    .collect(Collectors.toList());
+            fiveSbInfo.put("hRollClubTwoCarSum", storageBillPrintSixListBtype0.size()); //热 棒二车次数
+            fiveSbInfo.put("hRollClubTwoSum", storageBillPrintSixListBtype0.stream().mapToInt(StorageBillPrint::getAmountTotal).sum()); //热 棒二接收数
+
+            List<StorageBillPrint> storageBillPrintSixListBtype1 = storageBillPrintSixList.stream()
+                    .filter(storageBillPrint -> storageBillPrint.getBtype().equals("0") && storageBillPrint.getDestination().equals("棒三"))
+                    .collect(Collectors.toList());
+            fiveSbInfo.put("hRollClubThreeCarSum", storageBillPrintSixListBtype1.size()); //热 棒三车次数
+            fiveSbInfo.put("hRollClubThreeSum", storageBillPrintSixListBtype1.stream().mapToInt(StorageBillPrint::getAmountTotal).sum()); //热 棒三接收数
+
+            List<StorageBillPrint> storageBillPrintSixListBtype2 = storageBillPrintSixList.stream()
+                    .filter(storageBillPrint -> storageBillPrint.getBtype().equals("0") && storageBillPrint.getDestination().equals("上若"))
+                    .collect(Collectors.toList());
+            fiveSbInfo.put("hRollOutShippCarSum", storageBillPrintSixListBtype2.size()); //热 上若车次数
+            fiveSbInfo.put("hRollOutShippSum", storageBillPrintSixListBtype2.stream().mapToInt(StorageBillPrint::getAmountTotal).sum()); //热 上若接收数
+
+            List<StorageBillPrint> storageBillPrintSixColdList1 = storageBillPrintSixList.stream()
+                    .filter(storageBillPrint -> storageBillPrint.getBtype().equals("1") && storageBillPrint.getDestination().equals("棒二"))
+                    .collect(Collectors.toList());
+            fiveSbInfo.put("cRollClubTwoCarSum", storageBillPrintSixColdList1.size()); //冷 棒二车次数
+            fiveSbInfo.put("cRollClubTwoSum", storageBillPrintSixColdList1.stream().mapToInt(StorageBillPrint::getAmountTotal).sum()); //冷 棒二接收数
+
+
+            List<StorageBillPrint> storageBillPrintSixColdList2 = storageBillPrintSixList.stream()
+                    .filter(storageBillPrint -> storageBillPrint.getBtype().equals("1") && storageBillPrint.getDestination().equals("棒三"))
+                    .collect(Collectors.toList());
+            fiveSbInfo.put("cRollClubThreeCarSum", storageBillPrintSixColdList2.size()); //冷 棒三车次数
+            fiveSbInfo.put("cRollClubThreeSum", storageBillPrintSixColdList2.stream().mapToInt(StorageBillPrint::getAmountTotal).sum()); //冷 棒三接收数
+
+
+            List<StorageBillPrint> storageBillPrintSixColdList3 = storageBillPrintSixList.stream()
+                    .filter(storageBillPrint -> storageBillPrint.getBtype().equals("1") && storageBillPrint.getDestination().equals("上若"))
+                    .collect(Collectors.toList());
+            fiveSbInfo.put("cRollOutShippCarSum", storageBillPrintSixColdList3.size()); //冷 上若车次数
+            fiveSbInfo.put("cRollOutShippSum", storageBillPrintSixColdList3.stream().mapToInt(StorageBillPrint::getAmountTotal).sum()); //冷 上若接收数
+            sixSbInfoList.add(fiveSbInfo);
+            storageBilletControl.setSixSbInfoList(sixSbInfoList);
+        }
+
+        storageBillPrintAllList = Stream.concat(storageBillPrintFiveList.stream(), storageBillPrintSixList.stream()).collect(Collectors.toList());
+        storageBillPrintAllList.sort(Comparator.comparing(StorageBillPrint::getArrivalTime).reversed());
+        storageBilletControl.setStorageBillPrintList(storageBillPrintAllList);
+        return Result.OK(storageBilletControl);
+    }
+
+    /**
+     * 获取6#班次数据
+     * @param ccmNo
+     * @param shift
+     * @param shiftGroup
+     * @return
+     */
+    private BilletHotsendChangeShift handleBilletHotsendChangeShift(String ccmNo, String shift, String shiftGroup) {
+        LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(BilletHotsendChangeShift::getCcmNo, ccmNo)
+                .eq(BilletHotsendChangeShift::getShift, shift)
+                .eq(BilletHotsendChangeShift::getShiftGroup, shiftGroup)
+                .orderByDesc(BilletHotsendChangeShift::getCreateTime)
+                .last("limit 1");
+        return billetHotsendChangeShiftService.getOne(queryWrapper);
+    }
+
+    /**
+     * 获取装运单数据
+     * @param ccmNo
+     * @param classes
+     * @param createTime
+     * @return
+     */
+    private List<StorageBillPrint> handleStorageBillPrint(String ccmNo, String classes, Date createTime) {
+        LambdaQueryWrapper<StorageBillPrint> queryWrapper1 = new LambdaQueryWrapper<>();
+        queryWrapper1.eq(StorageBillPrint::getCcmNo, ccmNo)
+                .eq(StorageBillPrint::getClasses, classes)
+                .between(StorageBillPrint::getArrivalTime, createTime, new Date())
+                .orderByDesc(StorageBillPrint::getArrivalTime);
+        return storageBillPrintService.list(queryWrapper1);
+    }
 
 }

+ 15 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/storageBill/entity/StorageBilletControl.java

@@ -0,0 +1,15 @@
+package org.jeecg.modules.billet.storageBill.entity;
+
+import lombok.Data;
+import java.util.List;
+import java.util.Map;
+
+@Data
+public class StorageBilletControl {
+
+    private List<StorageBillPrint> storageBillPrintList;
+
+    private List<Map<String, Object>> fiveSbInfoList;
+
+    private List<Map<String, Object>> sixSbInfoList;
+}