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:
@@ -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));
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
33
ruoyi-mill/src/main/java/com/ruoyi/mill/domain/MillRoll.java
Normal file
33
ruoyi-mill/src/main/java/com/ruoyi/mill/domain/MillRoll.java
Normal 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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.mill.mapper.MillRollChangeMapper">
|
||||
|
||||
<resultMap id="BaseRM" type="com.ruoyi.mill.domain.MillRollChange">
|
||||
<id property="changeId" column="change_id"/>
|
||||
<result property="changeTime" column="change_time"/>
|
||||
<result property="changeStatus" column="change_status"/>
|
||||
<result property="upperWrNo" column="upper_wr_no"/>
|
||||
<result property="upperWrDia" column="upper_wr_dia"/>
|
||||
<result property="lowerWrNo" column="lower_wr_no"/>
|
||||
<result property="lowerWrDia" column="lower_wr_dia"/>
|
||||
<result property="upperIrNo" column="upper_ir_no"/>
|
||||
<result property="upperIrDia" column="upper_ir_dia"/>
|
||||
<result property="lowerIrNo" column="lower_ir_no"/>
|
||||
<result property="lowerIrDia" column="lower_ir_dia"/>
|
||||
<result property="upperBrNo" column="upper_br_no"/>
|
||||
<result property="upperBrDia" column="upper_br_dia"/>
|
||||
<result property="lowerBrNo" column="lower_br_no"/>
|
||||
<result property="lowerBrDia" column="lower_br_dia"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="cols">
|
||||
change_id, change_time, change_status,
|
||||
upper_wr_no, upper_wr_dia, lower_wr_no, lower_wr_dia,
|
||||
upper_ir_no, upper_ir_dia, lower_ir_no, lower_ir_dia,
|
||||
upper_br_no, upper_br_dia, lower_br_no, lower_br_dia,
|
||||
del_flag, create_by, create_time, update_by, update_time, remark
|
||||
</sql>
|
||||
|
||||
<select id="selectList" resultMap="BaseRM">
|
||||
SELECT <include refid="cols"/> FROM mill_roll_change
|
||||
WHERE del_flag = '0'
|
||||
<if test="changeStatus != null and changeStatus != ''">
|
||||
AND change_status = #{changeStatus}
|
||||
</if>
|
||||
ORDER BY change_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectLatest" resultMap="BaseRM">
|
||||
SELECT <include refid="cols"/> FROM mill_roll_change
|
||||
WHERE del_flag = '0'
|
||||
ORDER BY change_id DESC
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<insert id="insert" useGeneratedKeys="true" keyProperty="changeId">
|
||||
INSERT INTO mill_roll_change (
|
||||
change_time, change_status,
|
||||
upper_wr_no, upper_wr_dia, lower_wr_no, lower_wr_dia,
|
||||
upper_ir_no, upper_ir_dia, lower_ir_no, lower_ir_dia,
|
||||
upper_br_no, upper_br_dia, lower_br_no, lower_br_dia,
|
||||
del_flag, create_by, create_time, update_by, update_time, remark
|
||||
) VALUES (
|
||||
#{changeTime}, #{changeStatus},
|
||||
#{upperWrNo}, #{upperWrDia}, #{lowerWrNo}, #{lowerWrDia},
|
||||
#{upperIrNo}, #{upperIrDia}, #{lowerIrNo}, #{lowerIrDia},
|
||||
#{upperBrNo}, #{upperBrDia}, #{lowerBrNo}, #{lowerBrDia},
|
||||
'0', #{createBy}, NOW(), #{updateBy}, NOW(), #{remark}
|
||||
)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
92
ruoyi-mill/src/main/resources/mapper/mill/MillRollMapper.xml
Normal file
92
ruoyi-mill/src/main/resources/mapper/mill/MillRollMapper.xml
Normal file
@@ -0,0 +1,92 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.mill.mapper.MillRollMapper">
|
||||
|
||||
<resultMap id="BaseRM" type="com.ruoyi.mill.domain.MillRoll">
|
||||
<id property="rollId" column="roll_id"/>
|
||||
<result property="rollNo" column="roll_no"/>
|
||||
<result property="rollType" column="roll_type"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="initialDia" column="initial_dia"/>
|
||||
<result property="currentDia" column="current_dia"/>
|
||||
<result property="flag" column="flag"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="cols">
|
||||
roll_id, roll_no, roll_type, status, initial_dia, current_dia,
|
||||
flag, del_flag, create_by, create_time, update_by, update_time, remark
|
||||
</sql>
|
||||
|
||||
<select id="selectList" resultMap="BaseRM">
|
||||
SELECT <include refid="cols"/> FROM mill_roll
|
||||
WHERE del_flag = '0'
|
||||
<if test="rollNo != null and rollNo != ''">
|
||||
AND roll_no LIKE CONCAT('%', #{rollNo}, '%')
|
||||
</if>
|
||||
<if test="rollType != null and rollType != ''">
|
||||
AND roll_type = #{rollType}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
ORDER BY roll_id ASC
|
||||
</select>
|
||||
|
||||
<select id="selectById" resultMap="BaseRM">
|
||||
SELECT <include refid="cols"/> FROM mill_roll
|
||||
WHERE roll_id = #{rollId} AND del_flag = '0'
|
||||
</select>
|
||||
|
||||
<insert id="insert" useGeneratedKeys="true" keyProperty="rollId">
|
||||
INSERT INTO mill_roll (
|
||||
roll_no, roll_type, status, initial_dia, current_dia,
|
||||
flag, del_flag, create_by, create_time, update_by, update_time, remark
|
||||
) VALUES (
|
||||
#{rollNo}, #{rollType},
|
||||
<choose>
|
||||
<when test="status != null and status != ''">#{status}</when>
|
||||
<otherwise>'Offline'</otherwise>
|
||||
</choose>,
|
||||
#{initialDia}, #{currentDia},
|
||||
#{flag}, '0',
|
||||
#{createBy}, NOW(), #{updateBy}, NOW(), #{remark}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="update">
|
||||
UPDATE mill_roll
|
||||
<set>
|
||||
<if test="rollNo != null and rollNo != ''">roll_no = #{rollNo},</if>
|
||||
<if test="rollType != null and rollType != ''">roll_type = #{rollType},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="initialDia != null">initial_dia = #{initialDia},</if>
|
||||
<if test="currentDia != null">current_dia = #{currentDia},</if>
|
||||
<if test="flag != null">flag = #{flag},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
update_by = #{updateBy},
|
||||
update_time = NOW()
|
||||
</set>
|
||||
WHERE roll_id = #{rollId} AND del_flag = '0'
|
||||
</update>
|
||||
|
||||
<update id="deleteByIds">
|
||||
UPDATE mill_roll SET del_flag = '2', update_time = NOW()
|
||||
WHERE roll_id IN
|
||||
<foreach collection="array" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="updateStatus">
|
||||
UPDATE mill_roll SET status = #{status}, update_time = NOW()
|
||||
WHERE roll_id = #{rollId}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user