feat(mes/roll): 新增轧辊磨削记录通用查询和报表页面

1. 新增通用查询接口,支持按轧辊ID、产线ID、时间范围筛选磨削记录
2. 重构后端列表接口,支持不传轧辊ID查询全部记录
3. 修复硬度字段类型转换问题,将未倒角转为0数值
4. 新增磨辊报表页面,支持统计分析和图表展示
This commit is contained in:
2026-05-25 17:31:46 +08:00
parent 95c23462c9
commit 6f7a85025d
8 changed files with 505 additions and 8 deletions

View File

@@ -26,10 +26,17 @@ public class MesRollGrindController extends BaseController {
private final IMesRollGrindService iMesRollGrindService;
/** 查询某轧辊的磨削记录列表 */
/** 查询磨削记录列表(不传 rollId 时返回全部,支持时间范围和产线筛选) */
@GetMapping("/list")
public R<List<MesRollGrindVo>> list(@NotNull(message = "轧辊ID不能为空") @RequestParam Long rollId) {
return R.ok(iMesRollGrindService.listByRoll(rollId));
public R<List<MesRollGrindVo>> list(
@RequestParam(required = false) Long rollId,
@RequestParam(required = false) Long lineId,
@RequestParam(required = false) String beginTime,
@RequestParam(required = false) String endTime) {
if (rollId != null) {
return R.ok(iMesRollGrindService.listByRoll(rollId));
}
return R.ok(iMesRollGrindService.listByQuery(null, lineId, beginTime, endTime));
}
/** 按年份查询月度汇总 */

View File

@@ -16,6 +16,12 @@ public interface MesRollGrindMapper extends BaseMapperPlus<MesRollGrindMapper, M
/** 查询某轧辊全部磨削记录(按时间升序) */
List<MesRollGrindVo> selectByRollId(@Param("rollId") Long rollId);
/** 通用查询(所有参数可选) */
List<MesRollGrindVo> selectList(@Param("rollId") Long rollId,
@Param("lineId") Long lineId,
@Param("beginTime") String beginTime,
@Param("endTime") String endTime);
/** 按年份统计每月磨削量 { month, grindCount, totalGrindAmount } */
List<Map<String, Object>> selectMonthlyStats(@Param("rollId") Long rollId, @Param("year") int year);
}

View File

@@ -14,6 +14,9 @@ public interface IMesRollGrindService {
/** 查询某轧辊全部磨削记录 */
List<MesRollGrindVo> listByRoll(Long rollId);
/** 通用查询(所有参数可选) */
List<MesRollGrindVo> listByQuery(Long rollId, Long lineId, String beginTime, String endTime);
/** 新增磨削记录,同步更新轧辊当前直径和磨削次数 */
Long addGrind(MesRollGrindBo bo);

View File

@@ -34,6 +34,11 @@ public class MesRollGrindServiceImpl implements IMesRollGrindService {
return baseMapper.selectByRollId(rollId);
}
@Override
public List<MesRollGrindVo> listByQuery(Long rollId, Long lineId, String beginTime, String endTime) {
return baseMapper.selectList(rollId, lineId, beginTime, endTime);
}
@Override
@Transactional(rollbackFor = Exception.class)
public Long addGrind(MesRollGrindBo bo) {

View File

@@ -5,12 +5,29 @@
<select id="selectByRollId" resultType="com.klp.mes.roll.domain.vo.MesRollGrindVo">
SELECT grind_id, roll_id, roll_no, grind_time, team,
dia_before, dia_after, grind_amount, roll_shape,
flaw_result, hardness, operator, remark, create_time
flaw_result,
CASE WHEN hardness = '未倒角' THEN 0 ELSE CAST(hardness AS DECIMAL(10,1)) END AS hardness,
operator, remark, create_time
FROM mes_roll_grind
WHERE del_flag = 0 AND roll_id = #{rollId}
ORDER BY grind_time ASC, grind_id ASC
</select>
<select id="selectList" resultType="com.klp.mes.roll.domain.vo.MesRollGrindVo">
SELECT grind_id, roll_id, roll_no, grind_time, team,
dia_before, dia_after, grind_amount, roll_shape,
flaw_result,
CASE WHEN hardness = '未倒角' THEN 0 ELSE CAST(hardness AS DECIMAL(10,1)) END AS hardness,
operator, remark, create_time
FROM mes_roll_grind
WHERE del_flag = 0
<if test="rollId != null">AND roll_id = #{rollId}</if>
<if test="lineId != null">AND line_id = #{lineId}</if>
<if test="beginTime != null and beginTime != ''">AND grind_time &gt;= #{beginTime}</if>
<if test="endTime != null and endTime != ''">AND grind_time &lt;= #{endTime}</if>
ORDER BY grind_time ASC, grind_id ASC
</select>
<select id="selectMonthlyStats" resultType="map">
SELECT
DATE_FORMAT(grind_time, '%Y-%m') AS month,