This commit is contained in:
2025-09-26 17:53:42 +08:00
7 changed files with 78 additions and 2 deletions

View File

@@ -0,0 +1,36 @@
package com.fizz.business.controller;
import com.fizz.business.service.impl.SegmentService;
import com.fizz.business.vo.SegmentParamVO;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
@Tag(name ="历史曲线查询接口")
@RestController
@RequestMapping("/api/segment")
@Anonymous
public class SegmentController {
@Resource
SegmentService segmentService;
@GetMapping("/getSegmentHistory")
@Operation(summary ="根据钢卷号和参数查询历史曲线")
public R<List<SegmentParamVO>> queryParamByEnCoilId(String enCoilID, String paramField) {
if (enCoilID == null || paramField == null) {
return R.fail("参数不能为空");
}
return R.ok(segmentService.queryParamByEnCoilId(enCoilID, paramField),"查询历史曲线成功");
}
}

View File

@@ -4,9 +4,12 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fizz.business.domain.PdoStripvalue; import com.fizz.business.domain.PdoStripvalue;
import com.fizz.business.domain.Segment; import com.fizz.business.domain.Segment;
import com.fizz.business.dto.SegmentDTO; import com.fizz.business.dto.SegmentDTO;
import com.fizz.business.vo.SegmentParamVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* <p> * <p>
* 各机张力,电流等架跟踪表 Mapper 接口 * 各机张力,电流等架跟踪表 Mapper 接口
@@ -21,4 +24,8 @@ public interface SegmentMapper extends BaseMapper<SegmentDTO> {
PdoStripvalue getStripValue(@Param("entryMatId") String entryMatId, @Param("startPos") double startPos, @Param("endPos") double endPos); PdoStripvalue getStripValue(@Param("entryMatId") String entryMatId, @Param("startPos") double startPos, @Param("endPos") double endPos);
Segment getLatestRecord(); Segment getLatestRecord();
List<SegmentParamVO> queryParamByEnCoilId(@Param("enCoilID") String enCoilID,
@Param("paramField") String paramField);
} }

View File

@@ -5,11 +5,13 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fizz.business.dto.SegmentDTO; import com.fizz.business.dto.SegmentDTO;
import com.fizz.business.mapper.SegmentMapper; import com.fizz.business.mapper.SegmentMapper;
import com.fizz.business.vo.SegmentParamVO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
@Service @Service
@@ -58,4 +60,12 @@ public class SegmentService {
System.out.println("段数据保存成功。钢卷号: " + segment.getEnCoilID() + ", 段号: " + segment.getSegNo()); System.out.println("段数据保存成功。钢卷号: " + segment.getEnCoilID() + ", 段号: " + segment.getSegNo());
} }
public List<SegmentParamVO> queryParamByEnCoilId(String enCoilID, String paramField) {
if (enCoilID == null || paramField == null) {
throw new IllegalArgumentException("参数不能为空");
}
return segmentMapper.queryParamByEnCoilId(enCoilID, paramField);
}
} }

View File

@@ -14,6 +14,7 @@ import com.fizz.business.service.TrackService;
import com.fizz.business.service.impl.SegmentService; import com.fizz.business.service.impl.SegmentService;
import com.fizz.business.utils.MatmapUtil; import com.fizz.business.utils.MatmapUtil;
import com.fizz.business.utils.WebSocketUtil; import com.fizz.business.utils.WebSocketUtil;
import com.fizz.business.vo.SegmentParamVO;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
@@ -151,7 +152,7 @@ public class SegmentTrackerService {
} }
} }
// 出厂判断
double exitPlantPos = stripPositionService.calculate(DeviceEnum.TR, celLength, cxlLength); double exitPlantPos = stripPositionService.calculate(DeviceEnum.TR, celLength, cxlLength);
if (segment.getTailPos().compareTo(BigDecimal.valueOf(exitPlantPos)) >= 0) { if (segment.getTailPos().compareTo(BigDecimal.valueOf(exitPlantPos)) >= 0) {
System.out.println("钢卷 " + segment.getEnCoilID() + " 的段号 " + segment.getSegNo() + " 已离开产线,开始持久化数据。"); System.out.println("钢卷 " + segment.getEnCoilID() + " 的段号 " + segment.getSegNo() + " 已离开产线,开始持久化数据。");
@@ -306,4 +307,6 @@ public class SegmentTrackerService {
} }
} }
} }
} }

View File

@@ -0,0 +1,11 @@
package com.fizz.business.vo;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class SegmentParamVO {
private Integer segNo;
private BigDecimal value;
}

View File

@@ -61,4 +61,13 @@
<select id="getLatestRecord" resultType="com.fizz.business.domain.Segment"> <select id="getLatestRecord" resultType="com.fizz.business.domain.Segment">
SELECT * FROM cpg_segment where id=(SELECT max(id) FROM cpg_segment) SELECT * FROM cpg_segment where id=(SELECT max(id) FROM cpg_segment)
</select> </select>
<select id="queryParamByEnCoilId" resultType="com.fizz.business.vo.SegmentParamVO">
SELECT seg_no AS segNo,
JSON_UNQUOTE(JSON_EXTRACT(total_values_json, CONCAT('$.', #{paramField}, '_avg'))) AS value
FROM cpl_segment_total
WHERE en_coil_id = #{enCoilID}
ORDER BY seg_no
</select>
</mapper> </mapper>