Procházet zdrojové kódy

定尺实时判断切换模式

qiangxuan před 3 dny
rodič
revize
4caf02a19b

+ 55 - 11
zgzt-sys-java/jeecg-module-conn/src/main/java/org/jeecg/modules/billetActual/service/impl/BilletHotsendBaseServiceImpl.java

@@ -280,6 +280,16 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 			return;
 		}
 
+		// 取钢坯号的第九位字符
+		ccmNo = Optional.ofNullable(billetNos)
+				.filter(s -> !s.isEmpty())
+				.map(s -> s.split(","))
+				.filter(arr -> arr.length > 0)
+				.map(arr -> arr[0])
+				.filter(num -> num.length() >= 9)
+				.map(num -> String.valueOf(num.charAt(8)))
+				.orElse("");
+		log.info("C端自动化热装,钢坯中截取的铸机号:{}", ccmNo);
 		String shiftGroup = shiftGroupHandle(ccmNo);
 		String shift = shiftHandle(ccmNo);
 		log.info("C端自动化热装缓存中的班组、班别:{}", shiftGroup + ":" + shift);
@@ -287,13 +297,14 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 			log.info("{}{}", "班组班别获取为空,C端自动化热装<保存>失败!", JSON.toJSON(jsonObject));
 			return;
 		}
+
 		BilletLiftingBill billetLiftingBill = new BilletLiftingBill();
 		// 独立保存行车吊运单
 		billetLiftingBill.setId(String.valueOf(IdWorker.getId()));
 		billetLiftingBill.setCcmNo(ccmNo);
-		billetLiftingBill.setBilletsNo(billetNos);
 		billetLiftingBill.setShiftGroup(shiftGroup);
 		billetLiftingBill.setShift(shift);
+		billetLiftingBill.setBilletsNo(billetNos);
 		billetLiftingBill.setVehicleNumber(jsonObject.getString("vehicleNumber"));
 		billetLiftingBill.setLocation(location);
 		billetLiftingBill.setAddress(address);
@@ -335,17 +346,7 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 				}
 			}
 		}
-		// 取钢坯号的第九位字符
-		ccmNo = Optional.ofNullable(billetNos)
-				.filter(s -> !s.isEmpty())
-				.map(s -> s.split(","))
-				.filter(arr -> arr.length > 0)
-				.map(arr -> arr[0])
-				.filter(num -> num.length() >= 9)
-				.map(num -> String.valueOf(num.charAt(8)))
-				.orElse("");
 
-		log.info("C端自动化热装,钢坯中截取的铸机号:{}", ccmNo);
 		// 更新装运单铸机号、班别、班组
 		if ("0".equals(isStorageBill.getCcmNo())) {
 			// 更新铸机号,到装运单
@@ -406,6 +407,8 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 			try {
 				billetLiftingBillUpdate.setHeatNo(getHeatNo(billetBasicInfoLists));
 				double totalWeight = billetBasicInfoLists.stream().mapToDouble(BilletBasicInfo::getBilletWeight).sum();
+				billetLiftingBillUpdate.setShiftGroup(shiftGroup);
+				billetLiftingBillUpdate.setShift(shift);
 				billetLiftingBillUpdate.setBilletWeight(totalWeight);
 				billetLiftingBillUpdate.setAssemblyNumber(getAssemblyNumber(billetBasicInfoLists));
 				billetLiftingBillService.updateById(billetLiftingBillUpdate);
@@ -600,6 +603,45 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 			throw new JeecgBootException("流号定尺集合不能为空!");
 		}
 
+
+		Map<Integer, String> strandNoMap = new HashMap<>();
+		strandNoMap.put(1, "one");
+		strandNoMap.put(2, "two");
+		strandNoMap.put(3, "three");
+		strandNoMap.put(4, "four");
+		strandNoMap.put(5, "five");
+		strandNoMap.put(6, "six");
+		strandNoMap.put(7, "seven");
+		strandNoMap.put(8, "eight");
+
+		// 遍历JSONArray并更新Redis缓存
+		for (Object obj : strandNoSizeArray) {
+			JSONObject item = (JSONObject) obj;
+			Integer strandNo = item.getInteger("strandNo");
+			Integer length = item.getInteger("length");
+			// 生成Redis键
+			String strandText = strandNoMap.getOrDefault(strandNo, String.valueOf(strandNo));
+			String redisKey = String.format("strandNo:%s:length:%s", strandText, ccmNo);
+			// 判断缓存是否存在
+			boolean keyExists = redisTemplate.hasKey(redisKey);
+			String newValue = length.toString();
+			if (!keyExists) {
+				// 缓存不存在,直接写入
+				redisTemplate.opsForValue().set(redisKey, newValue);
+				log.info("初始化缓存 - 键: {}, 值: {}", redisKey, newValue);
+			} else {
+				// 缓存已存在,获取旧值并比较
+				String oldValue = oConvertUtils.getString(redisTemplate.opsForValue().get(redisKey));
+				if (!oldValue.equals(newValue)) {
+					// 新旧值不同,更新缓存并标记切割类型
+					String redisCuttoLengthKey = String.format("cut:to:length:%s", ccmNo);
+					redisTemplate.opsForValue().set(redisCuttoLengthKey, "2");
+				}
+				// 无论是否变更,都更新缓存(确保一致性)
+				redisTemplate.opsForValue().set(redisKey, newValue);
+			}
+		}
+
 		String redisCuttoLengthKey = String.format("cut:to:length:%s", ccmNo);
 		String cuttolengthType = !oConvertUtils.getString(redisTemplate.opsForValue().get(redisCuttoLengthKey))
 				.isEmpty() ? oConvertUtils.getString(redisTemplate.opsForValue().get(redisCuttoLengthKey)) : "";
@@ -616,6 +658,8 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 		// 存入 Redis
 		redisTemplate.opsForValue().set(redisKey, jsonValue);
 
+
+
 	}
 
     public void sendFurnaceChangeToMqtt(FurnaceChangeData data) {

+ 9 - 9
zgzt-sys-java/jeecg-module-conn/src/main/java/org/jeecg/modules/stackingAndLoadingVehicles/service/impl/StackingAndLoadingVehiclesServiceImpl.java

@@ -326,19 +326,12 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
 
         LoadingParams loadingParams = new LoadingParams();
         loadingParams.setBelongTable("stacking_and_loading_vehicles");
-
-        BilletHotsend billetHotsend = new BilletHotsend();
-        billetHotsend.setCcmNo(ccmNo);
-        billetHotsend.setShiftGroup(shiftGroupHandle(ccmNo));
-        billetHotsend.setShift(shiftHandle(ccmNo));
-        loadingParams.setBilletHotsend(billetHotsend);
-
         // 独立保存行车吊运单
         BilletLiftingBill billetLiftingBill = new BilletLiftingBill();
         billetLiftingBill.setId(String.valueOf(IdWorker.getId()));
         billetLiftingBill.setCcmNo(ccmNo);
-        billetLiftingBill.setShiftGroup(billetHotsend.getShiftGroup());
-        billetLiftingBill.setShift(billetHotsend.getShift());
+        billetLiftingBill.setShiftGroup(shiftGroupHandle(ccmNo));
+        billetLiftingBill.setShift(shiftHandle(ccmNo));
         billetLiftingBill.setAddress(address);
         billetLiftingBill.setLayer(layer);
         billetLiftingBill.setVehicleNumber(jsonObject.getString("vehicleNumber"));
@@ -419,6 +412,11 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
             log.info("{}{}", "班组班别获取为空,C端自动化垛位装车<保存>失败!", JSON.toJSON(isStorageBill));
             return;
         }
+        BilletHotsend billetHotsend = new BilletHotsend();
+        billetHotsend.setCcmNo(ccmNo);
+        billetHotsend.setShiftGroup(shiftGroup);
+        billetHotsend.setShift(shift);
+        loadingParams.setBilletHotsend(billetHotsend);
         // 更新装运单铸机号、班别、班组
         if ("0".equals(isStorageBill.getCcmNo())) {
             // 更新铸机号,到装运单
@@ -443,6 +441,8 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
         // 根据坯号查询吊运单信息。更新billetWeightTotal
         BilletLiftingBill billetLiftingBillUpdate = billetLiftingBillService.getById(billetLiftingBill.getId());
         if (oConvertUtils.isNotEmpty(billetLiftingBillUpdate)){
+            billetLiftingBillUpdate.setShiftGroup(shiftGroup);
+            billetLiftingBillUpdate.setShift(shift);
             // 维护吊运单,坯重、组坯号、炉号
             billetLiftingBillUpdate.setHeatNo(getHeatNo(billetBasicInfoList));
             billetLiftingBillUpdate.setBilletWeight(billetWeightTotal);