feat(roll): 完成轧辊管理全栈模块

DB:mill_roll(轧辊库)+ mill_roll_change(换辊记录),已执行到服务器

后端:
- MillRoll / MillRollChange domain
- Mapper 接口 + XML(keyProperty 正确:rollId/changeId)
- Service + ServiceImpl(换辊时自动更新轧辊 status 为 Online Use)
- MillRollController /mill/roll + MillRollChangeController /mill/rollChange

前端:
- api/mill/roll.js 8个接口函数
- views/mill/roll.vue 三段式布局
  ·上:换辊数据历史表格
  ·左下:当前辊系参数(6辊图形 CSS 圆圈 + 编号/径/时间展示)
  ·右下:轧辊库表格 + 条件查询 + 更换/添加/修改/删除操作
- 路由注册 /mill/roll

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-29 13:53:37 +08:00
parent c4dc5ded57
commit 01b6b810a6
16 changed files with 1436 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
package com.ruoyi.mill.controller;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.mill.domain.MillRollChange;
import com.ruoyi.mill.service.IMillRollChangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/mill/rollChange")
public class MillRollChangeController extends BaseController {
@Autowired
private IMillRollChangeService changeService;
@GetMapping("/list")
public TableDataInfo list(MillRollChange query) {
startPage();
return getDataTable(changeService.selectList(query));
}
@GetMapping("/current")
public AjaxResult current() {
return AjaxResult.success(changeService.selectLatest());
}
@PostMapping
public AjaxResult add(@RequestBody MillRollChange change) {
return toAjax(changeService.addChange(change));
}
}

View File

@@ -0,0 +1,47 @@
package com.ruoyi.mill.controller;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.mill.domain.MillRoll;
import com.ruoyi.mill.service.IMillRollService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/mill/roll")
public class MillRollController extends BaseController {
@Autowired
private IMillRollService rollService;
@GetMapping("/list")
public TableDataInfo list(MillRoll query) {
startPage();
return getDataTable(rollService.selectList(query));
}
@GetMapping("/{id}")
public AjaxResult getInfo(@PathVariable Long id) {
return AjaxResult.success(rollService.selectById(id));
}
@PostMapping
public AjaxResult add(@RequestBody MillRoll roll) {
int rows = rollService.insert(roll);
if (rows > 0) {
return AjaxResult.success(roll.getRollId());
}
return AjaxResult.error("新增失败");
}
@PutMapping
public AjaxResult edit(@RequestBody MillRoll roll) {
return toAjax(rollService.update(roll));
}
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(rollService.deleteByIds(ids));
}
}

View File

@@ -0,0 +1,33 @@
package com.ruoyi.mill.domain;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import java.math.BigDecimal;
/** 轧辊库 */
@Data
public class MillRoll extends BaseEntity {
private Long rollId;
/** 轧辊编号 */
private String rollNo;
/** 轧辊类型 WR/IR/BR */
private String rollType;
/** 使用状态 */
private String status;
/** 初始辊径(mm) */
private BigDecimal initialDia;
/** 当前辊径(mm) */
private BigDecimal currentDia;
/** 标志位 */
private String flag;
/** 删除标志 0正常 2删除 */
private String delFlag;
}

View File

@@ -0,0 +1,60 @@
package com.ruoyi.mill.domain;
import com.ruoyi.common.core.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/** 换辊记录 */
@Data
public class MillRollChange extends BaseEntity {
private Long changeId;
/** 换辊时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date changeTime;
/** 换辊状态 */
private String changeStatus;
/** 上工作辊编号 */
private String upperWrNo;
/** 上工作辊径(mm) */
private BigDecimal upperWrDia;
/** 下工作辊编号 */
private String lowerWrNo;
/** 下工作辊径(mm) */
private BigDecimal lowerWrDia;
/** 上中间辊编号 */
private String upperIrNo;
/** 上中间辊径(mm) */
private BigDecimal upperIrDia;
/** 下中间辊编号 */
private String lowerIrNo;
/** 下中间辊径(mm) */
private BigDecimal lowerIrDia;
/** 上支承辊编号 */
private String upperBrNo;
/** 上支承辊径(mm) */
private BigDecimal upperBrDia;
/** 下支承辊编号 */
private String lowerBrNo;
/** 下支承辊径(mm) */
private BigDecimal lowerBrDia;
/** 删除标志 0正常 2删除 */
private String delFlag;
}

View File

@@ -0,0 +1,13 @@
package com.ruoyi.mill.mapper;
import com.ruoyi.mill.domain.MillRollChange;
import java.util.List;
public interface MillRollChangeMapper {
List<MillRollChange> selectList(MillRollChange query);
MillRollChange selectLatest();
int insert(MillRollChange change);
}

View File

@@ -0,0 +1,20 @@
package com.ruoyi.mill.mapper;
import com.ruoyi.mill.domain.MillRoll;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface MillRollMapper {
List<MillRoll> selectList(MillRoll query);
MillRoll selectById(Long rollId);
int insert(MillRoll roll);
int update(MillRoll roll);
int deleteByIds(Long[] ids);
int updateStatus(@Param("rollId") Long rollId, @Param("status") String status);
}

View File

@@ -0,0 +1,13 @@
package com.ruoyi.mill.service;
import com.ruoyi.mill.domain.MillRollChange;
import java.util.List;
public interface IMillRollChangeService {
List<MillRollChange> selectList(MillRollChange query);
MillRollChange selectLatest();
int addChange(MillRollChange change);
}

View File

@@ -0,0 +1,17 @@
package com.ruoyi.mill.service;
import com.ruoyi.mill.domain.MillRoll;
import java.util.List;
public interface IMillRollService {
List<MillRoll> selectList(MillRoll query);
MillRoll selectById(Long rollId);
int insert(MillRoll roll);
int update(MillRoll roll);
int deleteByIds(Long[] ids);
}

View File

@@ -0,0 +1,77 @@
package com.ruoyi.mill.service.impl;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.mill.domain.MillRoll;
import com.ruoyi.mill.domain.MillRollChange;
import com.ruoyi.mill.mapper.MillRollChangeMapper;
import com.ruoyi.mill.mapper.MillRollMapper;
import com.ruoyi.mill.service.IMillRollChangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
@Service
public class MillRollChangeServiceImpl implements IMillRollChangeService {
@Autowired
private MillRollChangeMapper changeMapper;
@Autowired
private MillRollMapper rollMapper;
@Override
public List<MillRollChange> selectList(MillRollChange query) {
return changeMapper.selectList(query);
}
@Override
public MillRollChange selectLatest() {
return changeMapper.selectLatest();
}
@Override
@Transactional(rollbackFor = Exception.class)
public int addChange(MillRollChange change) {
String user = SecurityUtils.getUsername();
change.setCreateBy(user);
change.setUpdateBy(user);
change.setDelFlag("0");
if (change.getChangeTime() == null) {
change.setChangeTime(new Date());
}
if (change.getChangeStatus() == null || change.getChangeStatus().isEmpty()) {
change.setChangeStatus("新辊换上");
}
int rows = changeMapper.insert(change);
// Update roll status to "Online Use" for each populated roll position
updateRollStatusByNo(change.getUpperWrNo(), "Online Use");
updateRollStatusByNo(change.getLowerWrNo(), "Online Use");
updateRollStatusByNo(change.getUpperIrNo(), "Online Use");
updateRollStatusByNo(change.getLowerIrNo(), "Online Use");
updateRollStatusByNo(change.getUpperBrNo(), "Online Use");
updateRollStatusByNo(change.getLowerBrNo(), "Online Use");
return rows;
}
/**
* Find roll by roll_no and update its status.
* Silently skips if roll_no is blank or roll not found.
*/
private void updateRollStatusByNo(String rollNo, String newStatus) {
if (rollNo == null || rollNo.trim().isEmpty()) {
return;
}
MillRoll query = new MillRoll();
query.setRollNo(rollNo.trim());
List<MillRoll> list = rollMapper.selectList(query);
if (!list.isEmpty()) {
rollMapper.updateStatus(list.get(0).getRollId(), newStatus);
}
}
}

View File

@@ -0,0 +1,49 @@
package com.ruoyi.mill.service.impl;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.mill.domain.MillRoll;
import com.ruoyi.mill.mapper.MillRollMapper;
import com.ruoyi.mill.service.IMillRollService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class MillRollServiceImpl implements IMillRollService {
@Autowired
private MillRollMapper rollMapper;
@Override
public List<MillRoll> selectList(MillRoll query) {
return rollMapper.selectList(query);
}
@Override
public MillRoll selectById(Long rollId) {
return rollMapper.selectById(rollId);
}
@Override
public int insert(MillRoll roll) {
String user = SecurityUtils.getUsername();
roll.setCreateBy(user);
roll.setUpdateBy(user);
roll.setDelFlag("0");
if (roll.getStatus() == null || roll.getStatus().isEmpty()) {
roll.setStatus("Offline");
}
return rollMapper.insert(roll);
}
@Override
public int update(MillRoll roll) {
roll.setUpdateBy(SecurityUtils.getUsername());
return rollMapper.update(roll);
}
@Override
public int deleteByIds(Long[] ids) {
return rollMapper.deleteByIds(ids);
}
}