Compare commits

..

1 Commits

Author SHA1 Message Date
6acb7b4b40 refactor(mill): 优化轧辊备用管理的数据查询和状态更新逻辑
- 修改 MesRollInfoMapper 中条件更新状态方法的参数命名,提升可读性
- 更新 MesRollStandbyMapper 查询接口返回类型为 MesRollStandbyVo
- 重构 MesRollStandbyMapper XML 映射文件中的查询语句,增加位置标签字段
- 将清空操作从物理删除改为逻辑删除,保留数据记录
- 在 MesRollStandbyVo 中新增 positionLabel、remark 和 createTime 字段
- 调整控制器注解配置,移除权限校验并简化接口定义
2026-06-12 10:26:47 +08:00
7 changed files with 53 additions and 24 deletions

View File

@@ -104,14 +104,12 @@ public class MesRollStandbyController extends BaseController
}
/**
* 清空指定机架所有备辊,同时回退轧辊状态
* 清空指定产线+机架的全部下批轧辊
* DELETE /mill/standby/clear?lineId=xxx&standNo=1%23
*/
@PreAuthorize("@ss.hasPermi('mill:standby:remove')")
@Log(title = "下批轧辊(待换上)", businessType = BusinessType.DELETE)
@Log(title = "下批轧辊", businessType = BusinessType.DELETE)
@DeleteMapping("/clear")
public AjaxResult clearByStand(@RequestParam Long lineId, @RequestParam String standNo)
{
public AjaxResult clear(Long lineId, @RequestParam String standNo) {
return toAjax(mesRollStandbyService.clearByStand(lineId, standNo));
}
}

View File

@@ -14,10 +14,14 @@ public class MesRollStandbyVo {
private String rollNo;
private String rollType;
private String position;
/** 辊位中文标签(上支撑辊/上工作辊/下工作辊/下支撑辊) */
private String positionLabel;
private BigDecimal diameter;
private BigDecimal roughness;
private BigDecimal crown;
private Date readyTime;
private String remark;
private Date createTime;
public Long getStandbyId() { return standbyId; }
public void setStandbyId(Long standbyId) { this.standbyId = standbyId; }
@@ -37,6 +41,9 @@ public class MesRollStandbyVo {
public String getPosition() { return position; }
public void setPosition(String position) { this.position = position; }
public String getPositionLabel() { return positionLabel; }
public void setPositionLabel(String positionLabel) { this.positionLabel = positionLabel; }
public BigDecimal getDiameter() { return diameter; }
public void setDiameter(BigDecimal diameter) { this.diameter = diameter; }
@@ -48,4 +55,10 @@ public class MesRollStandbyVo {
public Date getReadyTime() { return readyTime; }
public void setReadyTime(Date readyTime) { this.readyTime = readyTime; }
public String getRemark() { return remark; }
public void setRemark(String remark) { this.remark = remark; }
public Date getCreateTime() { return createTime; }
public void setCreateTime(Date createTime) { this.createTime = createTime; }
}

View File

@@ -36,10 +36,9 @@ public interface MesRollInfoMapper {
int updateCurrentDia(@Param("rollId") Long rollId, @Param("currentDia") BigDecimal currentDia);
/**
* 条件更新轧辊状态 — 仅当当前状态为 oldStatus 时才更新为 newStatus
* 用于清空备辊时安全回退:避免把已上机的轧辊状态改错
* 条件更新仅当当前状态等于 onlyIfStatus 时才更新(用于避免误覆盖已 Online 的辊)
*/
int updateStatusByRollNoIfStatus(@Param("rollNo") String rollNo,
@Param("newStatus") String newStatus,
@Param("oldStatus") String oldStatus);
@Param("status") String status,
@Param("onlyIfStatus") String onlyIfStatus);
}

View File

@@ -2,6 +2,7 @@ package com.ruoyi.mill.mapper;
import java.util.List;
import com.ruoyi.mill.domain.MesRollStandby;
import com.ruoyi.mill.domain.MesRollStandbyVo;
import org.apache.ibatis.annotations.Param;
/**
@@ -67,7 +68,7 @@ public interface MesRollStandbyMapper
* @param standNo 机架号
* @return 备辊列表 (VO)
*/
public List<MesRollStandby> selectByStand(@Param("lineId") Long lineId, @Param("standNo") String standNo);
public List<MesRollStandbyVo> selectByStand(@Param("lineId") Long lineId, @Param("standNo") String standNo);
/**
* 清空指定机架的所有备辊记录

View File

@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.mill.mapper.MesRollStandbyMapper;
import com.ruoyi.mill.domain.MesRollStandby;
import com.ruoyi.mill.domain.MesRollStandbyVo;
import com.ruoyi.mill.service.IMesRollStandbyService;
import com.ruoyi.common.utils.StringUtils;
@@ -113,9 +114,9 @@ public class MesRollStandbyServiceImpl implements IMesRollStandbyService
@Transactional(rollbackFor = Exception.class)
public Boolean clearByStand(Long lineId, String standNo) {
// 先查出所有辊号再清空
List<MesRollStandby> list = mesRollStandbyMapper.selectByStand(lineId, standNo);
List<MesRollStandbyVo> list = mesRollStandbyMapper.selectByStand(lineId, standNo);
int rows = mesRollStandbyMapper.clearByStand(lineId, standNo);
for (MesRollStandby vo : list) {
for (MesRollStandbyVo vo : list) {
if (StringUtils.isNotBlank(vo.getRollNo())) {
// 只有仍处于 Standby 状态时才回退为 Offline换辊后已变 Online 的不动)
rollInfoMapper.updateStatusByRollNoIfStatus(vo.getRollNo(), "Offline", "Standby");

View File

@@ -171,13 +171,10 @@
WHERE del_flag = 0 AND roll_id = #{rollId}
</update>
<!-- 条件更新轧辊状态 — 仅当当前状态为 oldStatus 时才更新 -->
<update id="updateStatusByRollNoIfStatus">
UPDATE mes_roll_info
SET status = #{newStatus}, update_time = NOW()
WHERE del_flag = 0
AND roll_no = #{rollNo}
AND status = #{oldStatus}
SET status = #{status}, update_time = NOW()
WHERE del_flag = 0 AND roll_no = #{rollNo} AND status = #{onlyIfStatus}
</update>
</mapper>

View File

@@ -118,13 +118,33 @@
</foreach>
</delete>
<select id="selectByStand" resultMap="MesRollStandbyResult">
<include refid="selectMesRollStandbyVo"/>
where line_id = #{lineId} and stand_no = #{standNo}
<select id="selectByStand" resultType="com.ruoyi.mill.domain.MesRollStandbyVo">
SELECT
standby_id, line_id, stand_no, roll_no, roll_type, position,
CASE
WHEN roll_type = 'BR' AND position = 'UP' THEN '上支撑辊'
WHEN roll_type = 'WR' AND position = 'UP' THEN '上工作辊'
WHEN roll_type = 'WR' AND position = 'DOWN' THEN '下工作辊'
WHEN roll_type = 'BR' AND position = 'DOWN' THEN '下支撑辊'
ELSE CONCAT(position, roll_type)
END AS position_label,
diameter, roughness, crown, ready_time, remark, create_time
FROM mes_roll_standby
WHERE del_flag = 0
AND stand_no = #{standNo}
<if test="lineId != null">AND line_id = #{lineId}</if>
ORDER BY
FIELD(roll_type, 'BR', 'WR', 'WR', 'BR'),
FIELD(position, 'UP', 'UP', 'DOWN', 'DOWN')
</select>
<delete id="clearByStand">
delete from mes_roll_standby
where line_id = #{lineId} and stand_no = #{standNo}
</delete>
<!-- 逻辑删除指定产线+机架所有下批轧辊(清空) -->
<update id="clearByStand">
UPDATE mes_roll_standby
SET del_flag = 1
WHERE del_flag = 0
AND stand_no = #{standNo}
<if test="lineId != null">AND line_id = #{lineId}</if>
</update>
</mapper>