修改接口报错

This commit is contained in:
2025-09-18 16:35:33 +08:00
parent 008a6e0731
commit 66f8c800a3
9 changed files with 219 additions and 237 deletions

View File

@@ -58,7 +58,7 @@ public class SteelGradeInfoController {
queryWrapper.eq(StdAlloy::getGradeid, gradeid); // 只查询 gradeId 和 name 字段
// 查询 StdAlloy 数据
StdAlloy stdAlloyList = steelGradeInfoService.getById(queryWrapper);
StdAlloy stdAlloyList = steelGradeInfoService.getById(gradeid);
// 返回结果
return R.ok(stdAlloyList);

View File

@@ -1,36 +1,83 @@
package com.fizz.business.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class StdAlloy {
private Integer gradeid; // GRADEID
private String name; // NAME
private Integer origin; // ORIGIN
private Float sigma0; // SIGMA0
private Float firstSigma0; // FIRST_SIGMA0
private Float initSigma; // INIT_SIGMA
private Float ro; // RO
private Integer classId; // CLASSID
private Float a; // A
private Float b; // B
private Float c; // C
private Float d; // D
private Float kc0; // KC0
private Float kc1; // KC1
private Float kc2; // KC2
private Float kc3; // KC3
private Float kc4; // KC4
private Float nu; // NU
private Float e; // E
private Float chal; // CHAL
private Float temp0; // TEMP0
private Float strength; // STRENGTH
private Integer weldCode; // WELD_CODE
private LocalDateTime insDate; // INSDATE
@TableId("GRADEID")
private Integer gradeid; // 对应数据库字段 GRADEID
@TableField("NAME")
private String name; // 对应数据库字段 NAME
@TableField("ORIGIN")
private Integer origin; // 对应数据库字段 ORIGIN
@TableField("SIGMA0")
private Float sigma0; // 对应数据库字段 SIGMA0
@TableField("FIRST_SIGMA0")
private Float firstSigma0; // 对应数据库字段 FIRST_SIGMA0
@TableField("INIT_SIGMA")
private Float initSigma; // 对应数据库字段 INIT_SIGMA
@TableField("RO")
private Float ro; // 对应数据库字段 RO
@TableField("CLASSID")
private Integer classId; // 对应数据库字段 CLASSID
@TableField("A")
private Float a; // 对应数据库字段 A
@TableField("B")
private Float b; // 对应数据库字段 B
@TableField("C")
private Float c; // 对应数据库字段 C
@TableField("D")
private Float d; // 对应数据库字段 D
@TableField("KC0")
private Float kc0; // 对应数据库字段 KC0
@TableField("KC1")
private Float kc1; // 对应数据库字段 KC1
@TableField("KC2")
private Float kc2; // 对应数据库字段 KC2
@TableField("KC3")
private Float kc3; // 对应数据库字段 KC3
@TableField("KC4")
private Float kc4; // 对应数据库字段 KC4
@TableField("NU")
private Float nu; // 对应数据库字段 NU
@TableField("E")
private Float e; // 对应数据库字段 E
@TableField("CHAL")
private Float chal; // 对应数据库字段 CHAL
@TableField("TEMP0")
private Float temp0; // 对应数据库字段 TEMP0
@TableField("STRENGTH")
private Float strength; // 对应数据库字段 STRENGTH
@TableField("WELD_CODE")
private Integer weldCode; // 对应数据库字段 WELD_CODE
@TableField("INSDATE")
private LocalDateTime insDate; // 对应数据库字段 INSDATE
}

View File

@@ -18,6 +18,7 @@ import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
@@ -40,12 +41,15 @@ public class RedisCacheManager {
RedisTemplate<String, SegmentDTO> segmentRedisTemplate;
@Autowired
@Qualifier("redisTemplateOfMatmap")
RedisTemplate<String, MatmapDTO> matmapRedisTemplate;
@Autowired
@Qualifier("redisTemplateOfHead")
RedisTemplate<String, CoilHeadDTO> headRedisTemplate;
@Autowired
@Qualifier("redisTemplateOfCoilPos")
RedisTemplate<String, CoilPositionDTO> coilPosRedisTemplate;
@Autowired
@@ -144,7 +148,39 @@ public class RedisCacheManager {
}
public List<MatmapDTO> getMatmapList() {
return matmapRedisTemplate.opsForList().range(COIL_MATMAP_LIST_KEY, 0, -1);
List<MatmapDTO> rawList = matmapRedisTemplate.opsForList().range(COIL_MATMAP_LIST_KEY, 0, -1);
if (rawList == null) {
return null;
}
List<MatmapDTO> result = new ArrayList<>();
for (Object item : rawList) {
if (item == null) {
result.add(null);
continue;
}
// 如果是LinkedHashMap转换为MatmapDTO
if (item instanceof java.util.LinkedHashMap) {
try {
MatmapDTO dto = BeanUtil.toBean((java.util.LinkedHashMap<?, ?>) item, MatmapDTO.class);
result.add(dto);
} catch (Exception e) {
log.error("Failed to convert LinkedHashMap to MatmapDTO: {}", e.getMessage());
result.add(null);
}
}
// 如果已经是MatmapDTO直接添加
else if (item instanceof MatmapDTO) {
result.add((MatmapDTO) item);
}
else {
log.warn("Unexpected type in Redis list: {}", item.getClass().getName());
result.add(null);
}
}
return result;
}
public void setMatmap(int index, MatmapDTO matmap) {
@@ -152,7 +188,28 @@ public class RedisCacheManager {
}
public MatmapDTO getMatmap(int index) {
return matmapRedisTemplate.opsForList().index(COIL_MATMAP_LIST_KEY, index);
Object result = matmapRedisTemplate.opsForList().index(COIL_MATMAP_LIST_KEY, index);
if (result == null) {
return null;
}
// 如果是LinkedHashMap转换为MatmapDTO
if (result instanceof java.util.LinkedHashMap) {
try {
return BeanUtil.toBean((java.util.LinkedHashMap<?, ?>) result, MatmapDTO.class);
} catch (Exception e) {
log.error("Failed to convert LinkedHashMap to MatmapDTO: {}", e.getMessage());
return null;
}
}
// 如果已经是MatmapDTO直接返回
if (result instanceof MatmapDTO) {
return (MatmapDTO) result;
}
log.warn("Unexpected type in Redis: {}", result.getClass().getName());
return null;
}
public List<CoilHeadDTO> getHeadList() {

View File

@@ -153,10 +153,16 @@ public class CrmPdiPlanServiceImpl extends ServiceImpl<CrmPdiPlanMapper, CrmPdiP
public void changeStatus(ChangePlanStatusForm build) {
CrmPdiPlan pdiPlan = baseMapper.selectById(build.getId());
if (pdiPlan == null) {
log.error("未找到ID为{}的计划记录", build.getId());
return;
}
pdiPlan.setStatus(build.getOperation());
baseMapper.updateById(pdiPlan);
log.info("计划状态更新成功ID: {}, 新状态: {}", build.getId(), build.getOperation());
}
}

View File

@@ -27,6 +27,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -65,18 +66,45 @@ public class TrackServiceImpl implements TrackService {
public ReturnInfoVO getReturnInfo(int posIdx) {
MatmapDTO matmap = MatmapUtil.getMatmap(posIdx);
if (MatmapUtil.notReady(matmap)) {
log.warn("Matmap not ready for position index: {}", posIdx);
return ReturnInfoVO.builder()
.returnWeight(0.0)
.returnType(null)
.entryMatId(null)
.planId(null)
.build();
}
CrmPdiPlanVO planVO = crmPdiPlanService.getByCoilIdAndOperId(matmap.getPlanId());
if (planVO == null) {
log.warn("Plan not found for planId: {}", matmap.getPlanId());
return ReturnInfoVO.builder()
.returnWeight(0.0)
.returnType(null)
.entryMatId(matmap.getMatId())
.planId(Long.valueOf(matmap.getPlanId()))
.build();
}
String returnType = null;
double returnWt = 0;
if (Objects.equals(planVO.getStatus(), PlanStatusEnum.PRODUCING.name())) {
double coiledLength = redisCacheManager.getStripLocation();
double calcCoilWeight = CalcUtil.calcCoilWeight(coiledLength, planVO.getEntryThick(), planVO.getEntryWidth());
returnWt = planVO.getEntryWeight().divide(BigDecimal.valueOf(calcCoilWeight)).setScale(2, RoundingMode.HALF_UP).doubleValue();
if (planVO.getEntryWeight() != null && calcCoilWeight > 0) {
returnWt = planVO.getEntryWeight().divide(BigDecimal.valueOf(calcCoilWeight)).setScale(2, RoundingMode.HALF_UP).doubleValue();
} else {
log.warn("Invalid entry weight or calc coil weight: entryWeight={}, calcCoilWeight={}", planVO.getEntryWeight(), calcCoilWeight);
returnWt = 0.0;
}
returnType = HALF_RETURN.name();
} else if (Objects.equals(planVO.getStatus(), PlanStatusEnum.ONLINE.name())) {
returnWt = planVO.getEntryWeight().doubleValue();
if (planVO.getEntryWeight() != null) {
returnWt = planVO.getEntryWeight().doubleValue();
} else {
log.warn("Entry weight is null for planId: {}", planVO.getId());
returnWt = 0.0;
}
returnType = ALL_RETURN.name();
} else {
log.error("invalid plan status[{}], planId={}", planVO.getStatus(), planVO.getId());
@@ -133,6 +161,13 @@ public class TrackServiceImpl implements TrackService {
Integer currPosIdx = currDevice.getIdx();
MatmapDTO target = MatmapUtil.getMatmap(targetPosIdx);
MatmapDTO curr = MatmapUtil.getMatmap(currPosIdx);
if (curr == null || target == null) {
log.warn("Matmap is null - curr: {}, target: {}, currPosIdx: {}, targetPosIdx: {}",
curr, target, currPosIdx, targetPosIdx);
return;
}
if (Objects.equals(curr.getMatId(), target.getMatId())) {
return;
}
@@ -208,9 +243,18 @@ public class TrackServiceImpl implements TrackService {
@Override
public CoilPositionDTO getCoilPosition() {
CoilPositionDTO position = redisCacheManager.getCoilPosition();
if (position == null) {
log.warn("CoilPosition not found in Redis, creating empty position");
position = new CoilPositionDTO();
}
List<MatmapDTO> matmapList = redisCacheManager.getMatmapList();
if (matmapList == null) {
log.warn("MatmapList not found in Redis, using empty list");
matmapList = new ArrayList<>();
}
position.setMatMapList(matmapList);
return position;
}