|
@@ -1,14 +1,12 @@
|
|
|
package org.jeecg.modules.billetActual.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
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.DateUtils;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
-import org.jeecg.modules.billetActual.entity.BilletBasicInfo;
|
|
|
-import org.jeecg.modules.billetActual.entity.BilletHotsend;
|
|
|
-import org.jeecg.modules.billetActual.entity.BilletHotsendChangeShift;
|
|
|
-import org.jeecg.modules.billetActual.entity.BilletRulerConfig;
|
|
|
+import org.jeecg.modules.billetActual.entity.*;
|
|
|
import org.jeecg.modules.billetActual.mapper.BilletBasicInfoMapper;
|
|
|
import org.jeecg.modules.billetActual.mapper.BilletHotsendChangeShiftMapper;
|
|
|
import org.jeecg.modules.billetActual.mapper.BilletHotsendMapper;
|
|
@@ -23,6 +21,9 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @Description: 钢坯基础信息
|
|
@@ -48,11 +49,35 @@ public class BilletBasicInfoServiceImpl extends ServiceImpl<BilletBasicInfoMappe
|
|
|
|
|
|
@Autowired
|
|
|
BilletHotsendChangeShiftMapper billetHotsendChangeShiftMapper;
|
|
|
-
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void addC(BilletBasicInfo billetBasicInfo) {
|
|
|
try {
|
|
|
+ // 获取缓存中的定尺信息
|
|
|
+ String redisCuttoLengthKey = String.format("cut:to:length:%s", billetBasicInfo.getCcmNo());
|
|
|
+ String cuttolengthType = !oConvertUtils.getString(redisTemplate.opsForValue().get(redisCuttoLengthKey)).isEmpty() ? oConvertUtils.getString(redisTemplate.opsForValue().get(redisCuttoLengthKey)) : "";
|
|
|
+ if ("1".equals(cuttolengthType)){
|
|
|
+ log.info("{}{}", "手动模式定尺取缓存:", billetBasicInfo.getCcmNo());
|
|
|
+ String redisLengthKey = String.format("ccmno:length:stream:%s", billetBasicInfo.getCcmNo());
|
|
|
+ String redisLengthJson = !oConvertUtils.getString(redisTemplate.opsForValue().get(redisLengthKey)).isEmpty() ? oConvertUtils.getString(redisTemplate.opsForValue().get(redisLengthKey)) : "";
|
|
|
+ // 解析 JSON 并构建映射
|
|
|
+ Map<Integer, Integer> strandLengthMap = new HashMap<>();
|
|
|
+ if (!redisLengthJson.isEmpty()) {
|
|
|
+ try {
|
|
|
+ List<StrandLength> strandLengths = JSON.parseArray(redisLengthJson, StrandLength.class);
|
|
|
+ // 转换为Map:键为strandNo,值为length(流号无0,无需额外处理)
|
|
|
+ for (StrandLength item : strandLengths) {
|
|
|
+ strandLengthMap.put(item.getStrandNo(), item.getLength());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("解析流号长度缓存失败,JSON: {}, 错误: {}", redisLengthJson, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Integer strandNo = billetBasicInfo.getStrandNo();
|
|
|
+ Integer length = strandLengthMap.get(strandNo);
|
|
|
+ billetBasicInfo.setLength(length);
|
|
|
+ }
|
|
|
+
|
|
|
log.info("{}{}", "start钢坯基础信息接收到mqtt消息,开始处理逻辑:", DateUtils.date2Str(new Date(), DateUtils.datetimeFormat.get()));
|
|
|
String classShiftGroup = String.format("class:shift:group:%s", billetBasicInfo.getCcmNo()); // 班组
|
|
|
String classShift = String.format("class:shift:%s", billetBasicInfo.getCcmNo()); // 班别
|