双机架轧辊管理

This commit is contained in:
2026-05-07 11:19:32 +08:00
parent d71b1c4959
commit a5280923e1
32 changed files with 3088 additions and 4 deletions

View File

@@ -0,0 +1,86 @@
package com.klp.mes.roll.controller;
import com.klp.common.annotation.Log;
import com.klp.common.annotation.RepeatSubmit;
import com.klp.common.core.controller.BaseController;
import com.klp.common.core.domain.PageQuery;
import com.klp.common.core.domain.R;
import com.klp.common.core.page.TableDataInfo;
import java.math.BigDecimal;
import com.klp.common.enums.BusinessType;
import com.klp.mes.roll.domain.bo.MesRollChangeBo;
import com.klp.mes.roll.domain.vo.MesRollChangeVo;
import com.klp.mes.roll.service.IMesRollChangeService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
/**
* 换辊记录
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/mes/rollChange")
public class MesRollChangeController extends BaseController {
private final IMesRollChangeService iMesRollChangeService;
/** 分页列表(支持按机架、换辊类型、时间筛选) */
@GetMapping("/list")
public TableDataInfo<MesRollChangeVo> list(MesRollChangeBo bo, PageQuery pageQuery) {
return iMesRollChangeService.queryPageList(bo, pageQuery);
}
/**
* 查询指定机架当前在机轧辊(最近一次换辊记录)
* GET /mes/rollChange/current?standNo=1%23
*/
@GetMapping("/current")
public R<MesRollChangeVo> current(@RequestParam String standNo) {
return R.ok(iMesRollChangeService.queryCurrentByStand(standNo));
}
/**
* 查询指定机架当前轧辊的实时工作长度m
* GET /mes/rollChange/workLength?standNo=1%23
*/
@GetMapping("/workLength")
public R<BigDecimal> workLength(@RequestParam String standNo) {
return R.ok(iMesRollChangeService.queryRealtimeWorkLength(standNo));
}
/** 详情 */
@GetMapping("/{changeId}")
public R<MesRollChangeVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable Long changeId) {
return R.ok(iMesRollChangeService.queryById(changeId));
}
/** 新增换辊记录 */
@Log(title = "换辊记录", businessType = BusinessType.INSERT)
@RepeatSubmit
@PostMapping
public R<Long> add(@Validated @RequestBody MesRollChangeBo bo) {
return R.ok(iMesRollChangeService.addChange(bo));
}
/** 修改换辊记录 */
@Log(title = "换辊记录", businessType = BusinessType.UPDATE)
@RepeatSubmit
@PutMapping
public R<Void> edit(@Validated @RequestBody MesRollChangeBo bo) {
return toAjax(iMesRollChangeService.updateByBo(bo));
}
/** 删除换辊记录 */
@Log(title = "换辊记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{changeIds}")
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] changeIds) {
return toAjax(iMesRollChangeService.deleteWithValidByIds(Arrays.asList(changeIds), true));
}
}

View File

@@ -0,0 +1,110 @@
package com.klp.mes.roll.controller;
import com.klp.common.annotation.Log;
import com.klp.common.annotation.RepeatSubmit;
import com.klp.common.core.controller.BaseController;
import com.klp.common.core.domain.PageQuery;
import com.klp.common.core.domain.R;
import com.klp.common.core.page.TableDataInfo;
import com.klp.common.core.validate.AddGroup;
import com.klp.common.core.validate.EditGroup;
import com.klp.common.enums.BusinessType;
import com.klp.common.utils.poi.ExcelUtil;
import com.klp.mes.roll.domain.bo.MesRollInfoBo;
import com.klp.mes.roll.domain.vo.MesRollInfoVo;
import com.klp.mes.roll.service.IMesRollInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 轧辊库(轧辊总览页)
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/mes/rollInfo")
public class MesRollInfoController extends BaseController {
private final IMesRollInfoService iMesRollInfoService;
/** 分页列表 */
@GetMapping("/list")
public TableDataInfo<MesRollInfoVo> list(MesRollInfoBo bo, PageQuery pageQuery) {
return iMesRollInfoService.queryPageList(bo, pageQuery);
}
/** 状态统计卡片数据 */
@GetMapping("/stats")
public R<Map<String, Object>> stats() {
return R.ok(iMesRollInfoService.queryStatusStats());
}
/** 轧辊编号下拉列表(按辊型 + 状态过滤,均可为空) */
@GetMapping("/options")
public R<List<String>> options(String rollType, String status) {
return R.ok(iMesRollInfoService.queryRollNoList(rollType, status));
}
/** 详情 */
@GetMapping("/{rollId}")
public R<MesRollInfoVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable Long rollId) {
return R.ok(iMesRollInfoService.queryById(rollId));
}
/** 新增 */
@Log(title = "轧辊库", businessType = BusinessType.INSERT)
@RepeatSubmit
@PostMapping
public R<Long> add(@Validated(AddGroup.class) @RequestBody MesRollInfoBo bo) {
return R.ok(iMesRollInfoService.insertByBo(bo));
}
/** 修改 */
@Log(title = "轧辊库", businessType = BusinessType.UPDATE)
@RepeatSubmit
@PutMapping
public R<Void> edit(@Validated(EditGroup.class) @RequestBody MesRollInfoBo bo) {
return toAjax(iMesRollInfoService.updateByBo(bo));
}
/** 删除 */
@Log(title = "轧辊库", businessType = BusinessType.DELETE)
@DeleteMapping("/{rollIds}")
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] rollIds) {
return toAjax(iMesRollInfoService.deleteWithValidByIds(Arrays.asList(rollIds), true));
}
/** 封闭轧辊(状态改为 Scrapped / 报废) */
@Log(title = "轧辊库-封闭", businessType = BusinessType.UPDATE)
@PutMapping("/{rollId}/scrap")
public R<Void> scrap(@NotNull(message = "主键不能为空") @PathVariable Long rollId) {
return toAjax(iMesRollInfoService.scrapRoll(rollId));
}
/**
* 从换辊记录同步在线状态
* 将当前各机架在机轧辊的状态强制修正为 Online解决状态数据不一致问题
*/
@Log(title = "轧辊库-状态同步", businessType = BusinessType.UPDATE)
@PostMapping("/syncStatus")
public R<Void> syncStatus() {
iMesRollInfoService.syncStatusFromChange();
return R.ok();
}
/** 导出 */
@Log(title = "轧辊库", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(MesRollInfoBo bo, HttpServletResponse response) {
List<MesRollInfoVo> list = iMesRollInfoService.queryList(bo);
ExcelUtil.exportExcel(list, "轧辊数据", MesRollInfoVo.class, response);
}
}

View File

@@ -0,0 +1,77 @@
package com.klp.mes.roll.controller;
import com.klp.common.annotation.Log;
import com.klp.common.annotation.RepeatSubmit;
import com.klp.common.core.controller.BaseController;
import com.klp.common.core.domain.R;
import com.klp.common.core.validate.AddGroup;
import com.klp.common.enums.BusinessType;
import com.klp.mes.roll.domain.bo.MesRollStandbyBo;
import com.klp.mes.roll.domain.vo.MesRollStandbyVo;
import com.klp.mes.roll.service.IMesRollStandbyService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* 下批轧辊(备用辊)
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/mes/rollStandby")
public class MesRollStandbyController extends BaseController {
private final IMesRollStandbyService iMesRollStandbyService;
/**
* 查询指定机架的下批轧辊列表
* GET /mes/rollStandby/list?standNo=1%23
*/
@GetMapping("/list")
public R<List<MesRollStandbyVo>> list(@RequestParam String standNo) {
return R.ok(iMesRollStandbyService.queryByStand(standNo));
}
/** 详情 */
@GetMapping("/{standbyId}")
public R<MesRollStandbyVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable Long standbyId) {
return R.ok(iMesRollStandbyService.queryById(standbyId));
}
/** 新增下批轧辊 */
@Log(title = "下批轧辊", businessType = BusinessType.INSERT)
@RepeatSubmit
@PostMapping
public R<Long> add(@Validated(AddGroup.class) @RequestBody MesRollStandbyBo bo) {
return R.ok(iMesRollStandbyService.addStandby(bo));
}
/** 修改下批轧辊 */
@Log(title = "下批轧辊", businessType = BusinessType.UPDATE)
@RepeatSubmit
@PutMapping
public R<Void> edit(@Validated @RequestBody MesRollStandbyBo bo) {
return toAjax(iMesRollStandbyService.updateByBo(bo));
}
/** 删除单条下批轧辊,同时将辊状态恢复为 Offline */
@Log(title = "下批轧辊", businessType = BusinessType.DELETE)
@DeleteMapping("/{standbyId}")
public R<Void> remove(@NotNull(message = "主键不能为空") @PathVariable Long standbyId) {
return toAjax(iMesRollStandbyService.deleteById(standbyId));
}
/**
* 清空指定机架的全部下批轧辊
* DELETE /mes/rollStandby/clear?standNo=1%23
*/
@Log(title = "下批轧辊", businessType = BusinessType.DELETE)
@DeleteMapping("/clear")
public R<Void> clear(@RequestParam String standNo) {
return toAjax(iMesRollStandbyService.clearByStand(standNo));
}
}

View File

@@ -0,0 +1,64 @@
package com.klp.mes.roll.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.klp.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.Date;
/**
* 换辊记录 mes_roll_change
* 四辊轧机双机架1# / 2#
* 每次换辊记录 4 支辊:上工作辊、下工作辊、上支撑辊、下支撑辊
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("mes_roll_change")
public class MesRollChange extends BaseEntity {
private static final long serialVersionUID = 1L;
@TableId(value = "change_id")
private Long changeId;
/** 换辊编号 */
private String changeNo;
/** 换辊时间 */
private Date changeTime;
/** 机架号1# / 2# */
private String standNo;
/** 换辊类型: 计划换辊 / 紧急换辊 */
private String changeType;
/** 换辊状态 */
private String changeStatus;
/** 操作人 */
private String operator;
/** 上工作辊 */
private String upperWrNo;
private BigDecimal upperWrDia;
/** 下工作辊 */
private String lowerWrNo;
private BigDecimal lowerWrDia;
/** 上支撑辊 */
private String upperBrNo;
private BigDecimal upperBrDia;
/** 下支撑辊 */
private String lowerBrNo;
private BigDecimal lowerBrDia;
@TableLogic
private Integer delFlag;
}

View File

@@ -0,0 +1,70 @@
package com.klp.mes.roll.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.klp.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.Date;
/**
* 轧辊库 mes_roll_info
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("mes_roll_info")
public class MesRollInfo extends BaseEntity {
private static final long serialVersionUID = 1L;
@TableId(value = "roll_id")
private Long rollId;
/** 轧辊编号 */
private String rollNo;
/** 辊型: WR=工作辊 / IR=中间辊 / BR=支撑辊 */
private String rollType;
/** 状态: Offline / Standby / Online / Scrapped */
private String status;
/** 初始辊径(mm) */
private BigDecimal initialDia;
/** 当前辊径(mm) */
private BigDecimal currentDia;
/** 最小可用辊径(mm) */
private BigDecimal minDia;
/** 粗糙度 Ra(μm) */
private BigDecimal roughness;
/** 凸度(mm) */
private BigDecimal crown;
/** 材质 */
private String material;
/** 磨削次数 */
private Integer grindCount;
/** 累计轧制重量(t) */
private BigDecimal totalRolledWeight;
/** 累计轧制长度(m) */
private BigDecimal totalRolledLength;
/** 累计轧制卷数 */
private Integer totalRolledCount;
/** 制造日期 */
private Date manufactureDate;
@TableLogic
private Integer delFlag;
}

View File

@@ -0,0 +1,59 @@
package com.klp.mes.roll.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.klp.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.Date;
/**
* 下批轧辊(备用辊,等待换上) mes_roll_standby
*
* 每条记录代表一个具体辊位的备用辊,例如:
* 机架 1#、上工作辊位、辊号 WR-020
*
* 辊型rollTypeWR = 工作辊BR = 支撑辊
* 辊位positionUP = 上DOWN = 下
* 机架standNo1# / 2#
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("mes_roll_standby")
public class MesRollStandby extends BaseEntity {
private static final long serialVersionUID = 1L;
@TableId(value = "standby_id")
private Long standbyId;
/** 机架号1# / 2# */
private String standNo;
/** 轧辊编号(关联 mes_roll_info.roll_no */
private String rollNo;
/** 辊型WR工作辊/ BR支撑辊 */
private String rollType;
/** 辊位UP/ DOWN */
private String position;
/** 当前直径 */
private BigDecimal diameter;
/** 粗糙度 */
private BigDecimal roughness;
/** 凸度 */
private BigDecimal crown;
/** 备用就绪时间 */
private Date readyTime;
@TableLogic
private Integer delFlag;
}

View File

@@ -0,0 +1,53 @@
package com.klp.mes.roll.domain.bo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.klp.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.Date;
/**
* 换辊记录 业务对象
* 四辊轧机双机架1# / 2#
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class MesRollChangeBo extends BaseEntity {
private Long changeId;
private String changeNo;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date changeTime;
/** 机架号1# / 2#,列表筛选用 */
private String standNo;
/** 换辊类型(列表筛选用) */
private String changeType;
private String changeStatus;
private String operator;
/** 上工作辊 */
private String upperWrNo;
private BigDecimal upperWrDia;
/** 下工作辊 */
private String lowerWrNo;
private BigDecimal lowerWrDia;
/** 上支撑辊 */
private String upperBrNo;
private BigDecimal upperBrDia;
/** 下支撑辊 */
private String lowerBrNo;
private BigDecimal lowerBrDia;
private String remark;
}

View File

@@ -0,0 +1,57 @@
package com.klp.mes.roll.domain.bo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.klp.common.core.domain.BaseEntity;
import com.klp.common.core.validate.AddGroup;
import com.klp.common.core.validate.EditGroup;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;
/**
* 轧辊库 业务对象
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class MesRollInfoBo extends BaseEntity {
@NotNull(message = "轧辊ID不能为空", groups = EditGroup.class)
private Long rollId;
@NotBlank(message = "轧辊编号不能为空", groups = {AddGroup.class, EditGroup.class})
private String rollNo;
@NotBlank(message = "辊型不能为空", groups = {AddGroup.class, EditGroup.class})
private String rollType;
private String status;
private BigDecimal initialDia;
private BigDecimal currentDia;
private BigDecimal minDia;
private BigDecimal roughness;
private BigDecimal crown;
private String material;
private Integer grindCount;
private BigDecimal totalRolledWeight;
private BigDecimal totalRolledLength;
private Integer totalRolledCount;
@JsonFormat(pattern = "yyyy-MM-dd")
private Date manufactureDate;
private String remark;
}

View File

@@ -0,0 +1,48 @@
package com.klp.mes.roll.domain.bo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.klp.common.core.domain.BaseEntity;
import com.klp.common.core.validate.AddGroup;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import java.math.BigDecimal;
import java.util.Date;
/**
* 下批轧辊 业务对象
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class MesRollStandbyBo extends BaseEntity {
private Long standbyId;
/** 机架号1# / 2# */
@NotBlank(message = "机架号不能为空", groups = AddGroup.class)
private String standNo;
/** 轧辊编号 */
@NotBlank(message = "轧辊编号不能为空", groups = AddGroup.class)
private String rollNo;
/** 辊型WR / BR */
@NotBlank(message = "辊型不能为空", groups = AddGroup.class)
private String rollType;
/** 辊位UP / DOWN */
@NotBlank(message = "辊位不能为空", groups = AddGroup.class)
private String position;
private BigDecimal diameter;
private BigDecimal roughness;
private BigDecimal crown;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date readyTime;
private String remark;
}

View File

@@ -0,0 +1,57 @@
package com.klp.mes.roll.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* 换辊记录 视图对象
* 四辊轧机双机架1# / 2#
*/
@Data
public class MesRollChangeVo {
private static final long serialVersionUID = 1L;
private Long changeId;
private String changeNo;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date changeTime;
/** 机架号1# / 2# */
private String standNo;
private String changeType;
private String changeStatus;
private String operator;
/** 上工作辊 */
private String upperWrNo;
private BigDecimal upperWrDia;
/** 下工作辊 */
private String lowerWrNo;
private BigDecimal lowerWrDia;
/** 上支撑辊 */
private String upperBrNo;
private BigDecimal upperBrDia;
/** 下支撑辊 */
private String lowerBrNo;
private BigDecimal lowerBrDia;
private String remark;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/** 本次换辊方案的累计工作长度m由 WMS 卷料数据计算得出 */
private BigDecimal workLength;
}

View File

@@ -0,0 +1,70 @@
package com.klp.mes.roll.domain.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* 轧辊库 视图对象
*/
@Data
@ExcelIgnoreUnannotated
public class MesRollInfoVo {
private static final long serialVersionUID = 1L;
@ExcelProperty("轧辊ID")
private Long rollId;
@ExcelProperty("轧辊编号")
private String rollNo;
@ExcelProperty("辊型")
private String rollType;
@ExcelProperty("状态")
private String status;
@ExcelProperty("初始辊径(mm)")
private BigDecimal initialDia;
@ExcelProperty("当前辊径(mm)")
private BigDecimal currentDia;
@ExcelProperty("最小辊径(mm)")
private BigDecimal minDia;
@ExcelProperty("粗糙度")
private BigDecimal roughness;
@ExcelProperty("凸度(mm)")
private BigDecimal crown;
@ExcelProperty("材质")
private String material;
@ExcelProperty("磨削次数")
private Integer grindCount;
@ExcelProperty("累计重量(t)")
private BigDecimal totalRolledWeight;
@ExcelProperty("累计长度(m)")
private BigDecimal totalRolledLength;
@ExcelProperty("累计卷数")
private Integer totalRolledCount;
@ExcelProperty("制造日期")
private Date manufactureDate;
@ExcelProperty("备注")
private String remark;
private Date createTime;
private Date updateTime;
}

View File

@@ -0,0 +1,47 @@
package com.klp.mes.roll.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* 下批轧辊 视图对象
*/
@Data
public class MesRollStandbyVo {
private static final long serialVersionUID = 1L;
private Long standbyId;
/** 机架号1# / 2# */
private String standNo;
/** 轧辊编号 */
private String rollNo;
/** 辊型WR工作辊/ BR支撑辊 */
private String rollType;
/** 辊位UP/ DOWN */
private String position;
/** 辊位中文展示:上工作辊 / 下工作辊 / 上支撑辊 / 下支撑辊 */
private String positionLabel;
private BigDecimal diameter;
private BigDecimal roughness;
private BigDecimal crown;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date readyTime;
private String remark;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
}

View File

@@ -0,0 +1,30 @@
package com.klp.mes.roll.mapper;
import com.klp.common.core.mapper.BaseMapperPlus;
import com.klp.mes.roll.domain.MesRollChange;
import com.klp.mes.roll.domain.vo.MesRollChangeVo;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.Date;
/**
* 换辊记录 Mapper
*/
public interface MesRollChangeMapper extends BaseMapperPlus<MesRollChangeMapper, MesRollChange, MesRollChangeVo> {
/** 查询指定机架最新一次换辊记录(当前在机轧辊) */
MesRollChangeVo selectLatestByStand(@Param("standNo") String standNo);
/**
* 查询同机架下一次换辊时间(用于确定本次换辊的服务结束时刻)
* 返回 null 表示该辊仍在机
*/
Date selectNextChangeTime(@Param("standNo") String standNo, @Param("changeTime") Date changeTime);
/**
* 统计指定时间区间内的卷料实测长度之和mm→调用方除以1000转m
* endTime 为 null 时统计到当前时刻
*/
BigDecimal selectWorkLength(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
}

View File

@@ -0,0 +1,42 @@
package com.klp.mes.roll.mapper;
import com.klp.common.core.mapper.BaseMapperPlus;
import com.klp.mes.roll.domain.MesRollInfo;
import com.klp.mes.roll.domain.vo.MesRollInfoVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 轧辊库 Mapper
*/
public interface MesRollInfoMapper extends BaseMapperPlus<MesRollInfoMapper, MesRollInfo, MesRollInfoVo> {
/**
* 按状态统计数量(用于总览卡片)
*/
List<Map<String, Object>> selectStatusStats();
/**
* 查询轧辊编号列表(用于下拉选择,可按辊型和状态过滤)
*/
List<String> selectRollNoList(@Param("rollType") String rollType, @Param("status") String status);
/**
* 按轧辊编号查询(用于换辊时同步状态)
*/
MesRollInfo selectByRollNo(@Param("rollNo") String rollNo);
/**
* 更新轧辊状态
*/
int updateStatusByRollNo(@Param("rollNo") String rollNo, @Param("status") String status);
/**
* 条件更新:仅当辊当前状态等于 onlyIfStatus 时才更新(用于避免误覆盖已 Online 的辊)
*/
int updateStatusByRollNoIfStatus(@Param("rollNo") String rollNo,
@Param("status") String status,
@Param("onlyIfStatus") String onlyIfStatus);
}

View File

@@ -0,0 +1,20 @@
package com.klp.mes.roll.mapper;
import com.klp.common.core.mapper.BaseMapperPlus;
import com.klp.mes.roll.domain.MesRollStandby;
import com.klp.mes.roll.domain.vo.MesRollStandbyVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 下批轧辊 Mapper
*/
public interface MesRollStandbyMapper extends BaseMapperPlus<MesRollStandbyMapper, MesRollStandby, MesRollStandbyVo> {
/** 按机架查询下批轧辊列表 */
List<MesRollStandbyVo> selectByStand(@Param("standNo") String standNo);
/** 清空某机架的下批轧辊 */
int clearByStand(@Param("standNo") String standNo);
}

View File

@@ -0,0 +1,35 @@
package com.klp.mes.roll.service;
import com.klp.common.core.domain.PageQuery;
import com.klp.common.core.page.TableDataInfo;
import com.klp.mes.roll.domain.bo.MesRollChangeBo;
import com.klp.mes.roll.domain.vo.MesRollChangeVo;
import java.math.BigDecimal;
import java.util.Collection;
/**
* 换辊记录 Service 接口
*/
public interface IMesRollChangeService {
MesRollChangeVo queryById(Long changeId);
/** 查询指定机架当前在机轧辊(最新一次换辊记录) */
MesRollChangeVo queryCurrentByStand(String standNo);
TableDataInfo<MesRollChangeVo> queryPageList(MesRollChangeBo bo, PageQuery pageQuery);
/** 新增换辊记录,同步将涉及的轧辊状态更新为 Online */
Long addChange(MesRollChangeBo bo);
Boolean updateByBo(MesRollChangeBo bo);
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
/**
* 查询指定机架当前在机轧辊的实时工作长度m
* 从最近一次换辊时间到现在,统计 WMS 卷料实测长度之和
*/
BigDecimal queryRealtimeWorkLength(String standNo);
}

View File

@@ -0,0 +1,45 @@
package com.klp.mes.roll.service;
import com.klp.common.core.domain.PageQuery;
import com.klp.common.core.page.TableDataInfo;
import com.klp.mes.roll.domain.bo.MesRollInfoBo;
import com.klp.mes.roll.domain.vo.MesRollInfoVo;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* 轧辊库 Service 接口
*/
public interface IMesRollInfoService {
MesRollInfoVo queryById(Long rollId);
TableDataInfo<MesRollInfoVo> queryPageList(MesRollInfoBo bo, PageQuery pageQuery);
List<MesRollInfoVo> queryList(MesRollInfoBo bo);
/** 按状态统计(总览卡片) */
Map<String, Object> queryStatusStats();
/** 轧辊编号下拉列表status 为 null 时不过滤状态) */
List<String> queryRollNoList(String rollType, String status);
Long insertByBo(MesRollInfoBo bo);
Boolean updateByBo(MesRollInfoBo bo);
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
/** 封闭轧辊:状态设为 Scrapped */
Boolean scrapRoll(Long rollId);
/**
* 从换辊记录同步在线状态:
* 每个机架最新一次换辊记录中的 4 支辊 → Online
* 下批辊列表中的辊 → Standby已由 addStandby 维护,此处不重复处理);
* 其余不变,仅修正当前在机辊的状态数据不一致问题。
*/
void syncStatusFromChange();
}

View File

@@ -0,0 +1,29 @@
package com.klp.mes.roll.service;
import com.klp.mes.roll.domain.bo.MesRollStandbyBo;
import com.klp.mes.roll.domain.vo.MesRollStandbyVo;
import java.util.List;
/**
* 下批轧辊 Service 接口
*/
public interface IMesRollStandbyService {
MesRollStandbyVo queryById(Long standbyId);
/** 查询指定机架的下批轧辊列表 */
List<MesRollStandbyVo> queryByStand(String standNo);
/** 新增下批轧辊,同步将该辊状态更新为 Standby */
Long addStandby(MesRollStandbyBo bo);
/** 修改下批轧辊 */
Boolean updateByBo(MesRollStandbyBo bo);
/** 删除某条下批轧辊,同步将该辊状态恢复为 Offline */
Boolean deleteById(Long standbyId);
/** 清空指定机架的全部下批轧辊,并将对应辊状态恢复为 Offline */
Boolean clearByStand(String standNo);
}

View File

@@ -0,0 +1,140 @@
package com.klp.mes.roll.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.klp.common.core.domain.PageQuery;
import com.klp.common.core.page.TableDataInfo;
import com.klp.common.helper.LoginHelper;
import com.klp.common.utils.StringUtils;
import com.klp.mes.roll.domain.MesRollChange;
import com.klp.mes.roll.domain.bo.MesRollChangeBo;
import com.klp.mes.roll.domain.vo.MesRollChangeVo;
import com.klp.mes.roll.mapper.MesRollChangeMapper;
import com.klp.mes.roll.mapper.MesRollInfoMapper;
import com.klp.mes.roll.service.IMesRollChangeService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.List;
/**
* 换辊记录 Service 实现
*/
@RequiredArgsConstructor
@Service
public class MesRollChangeServiceImpl implements IMesRollChangeService {
private final MesRollChangeMapper baseMapper;
private final MesRollInfoMapper rollInfoMapper;
@Override
public MesRollChangeVo queryById(Long changeId) {
return baseMapper.selectVoById(changeId);
}
@Override
public MesRollChangeVo queryCurrentByStand(String standNo) {
return baseMapper.selectLatestByStand(standNo);
}
@Override
public TableDataInfo<MesRollChangeVo> queryPageList(MesRollChangeBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<MesRollChange> lqw = buildQueryWrapper(bo);
Page<MesRollChangeVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
// 为每条换辊记录计算工作长度(上辊时间 → 下辊时间,下辊时间为 null 时统计到 NOW()
for (MesRollChangeVo vo : result.getRecords()) {
Date endTime = baseMapper.selectNextChangeTime(vo.getStandNo(), vo.getChangeTime());
BigDecimal lengthMm = baseMapper.selectWorkLength(vo.getChangeTime(), endTime);
// mm 转 m保留 2 位小数
vo.setWorkLength(lengthMm == null ? BigDecimal.ZERO
: lengthMm.divide(BigDecimal.valueOf(1000), 2, RoundingMode.HALF_UP));
}
return TableDataInfo.build(result);
}
@Override
public BigDecimal queryRealtimeWorkLength(String standNo) {
MesRollChangeVo latest = baseMapper.selectLatestByStand(standNo);
if (latest == null || latest.getChangeTime() == null) {
return BigDecimal.ZERO;
}
BigDecimal lengthMm = baseMapper.selectWorkLength(latest.getChangeTime(), null);
return lengthMm == null ? BigDecimal.ZERO
: lengthMm.divide(BigDecimal.valueOf(1000), 2, RoundingMode.HALF_UP);
}
private LambdaQueryWrapper<MesRollChange> buildQueryWrapper(MesRollChangeBo bo) {
LambdaQueryWrapper<MesRollChange> lqw = Wrappers.lambdaQuery();
lqw.eq(StringUtils.isNotBlank(bo.getStandNo()), MesRollChange::getStandNo, bo.getStandNo());
lqw.eq(StringUtils.isNotBlank(bo.getChangeType()), MesRollChange::getChangeType, bo.getChangeType());
lqw.eq(StringUtils.isNotBlank(bo.getChangeStatus()), MesRollChange::getChangeStatus, bo.getChangeStatus());
if (bo.getChangeTime() != null) {
lqw.ge(MesRollChange::getChangeTime, bo.getChangeTime());
}
lqw.orderByDesc(MesRollChange::getChangeTime, MesRollChange::getChangeId);
return lqw;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Long addChange(MesRollChangeBo bo) {
MesRollChange add = BeanUtil.toBean(bo, MesRollChange.class);
if (StringUtils.isBlank(add.getChangeNo())) {
add.setChangeNo("RC" + IdUtil.fastSimpleUUID().substring(0, 8).toUpperCase());
}
// 换辊时间强制使用服务器当前时间
add.setChangeTime(new Date());
// 操作人取当前登录用户昵称
add.setOperator(LoginHelper.getNickName());
// 换辊类型固定为"计划换辊"(通过页面触发)
if (StringUtils.isBlank(add.getChangeType())) {
add.setChangeType("三级换辊");
}
// 换辊前:将上一批在机轧辊状态改为 Offline
MesRollChangeVo prev = baseMapper.selectLatestByStand(add.getStandNo());
if (prev != null) {
for (String rollNo : Arrays.asList(
prev.getUpperWrNo(), prev.getLowerWrNo(),
prev.getUpperBrNo(), prev.getLowerBrNo())) {
if (StringUtils.isNotBlank(rollNo)) {
rollInfoMapper.updateStatusByRollNo(rollNo, "Offline");
}
}
}
baseMapper.insert(add);
// 将本次换上的 4 支辊状态同步为 Online
List<String> rollNos = Arrays.asList(
add.getUpperWrNo(), add.getLowerWrNo(),
add.getUpperBrNo(), add.getLowerBrNo()
);
for (String rollNo : rollNos) {
if (StringUtils.isNotBlank(rollNo)) {
rollInfoMapper.updateStatusByRollNo(rollNo, "Online");
}
}
return add.getChangeId();
}
@Override
public Boolean updateByBo(MesRollChangeBo bo) {
MesRollChange update = BeanUtil.toBean(bo, MesRollChange.class);
return baseMapper.updateById(update) > 0;
}
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
return baseMapper.deleteBatchIds(ids) > 0;
}
}

View File

@@ -0,0 +1,137 @@
package com.klp.mes.roll.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.klp.common.core.domain.PageQuery;
import com.klp.common.core.page.TableDataInfo;
import com.klp.common.utils.StringUtils;
import com.klp.mes.roll.domain.MesRollInfo;
import com.klp.mes.roll.domain.bo.MesRollInfoBo;
import com.klp.mes.roll.domain.vo.MesRollInfoVo;
import com.klp.mes.roll.domain.vo.MesRollChangeVo;
import com.klp.mes.roll.mapper.MesRollChangeMapper;
import com.klp.mes.roll.mapper.MesRollInfoMapper;
import com.klp.mes.roll.service.IMesRollInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 轧辊库 Service 实现
*/
@RequiredArgsConstructor
@Service
public class MesRollInfoServiceImpl implements IMesRollInfoService {
private final MesRollInfoMapper baseMapper;
private final MesRollChangeMapper rollChangeMapper;
@Override
public MesRollInfoVo queryById(Long rollId) {
return baseMapper.selectVoById(rollId);
}
@Override
public TableDataInfo<MesRollInfoVo> queryPageList(MesRollInfoBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<MesRollInfo> lqw = buildQueryWrapper(bo);
Page<MesRollInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
@Override
public List<MesRollInfoVo> queryList(MesRollInfoBo bo) {
LambdaQueryWrapper<MesRollInfo> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
@Override
public Map<String, Object> queryStatusStats() {
List<Map<String, Object>> rows = baseMapper.selectStatusStats();
Map<String, Object> result = new HashMap<String, Object>(8);
int total = 0;
for (Map<String, Object> row : rows) {
String status = (String) row.get("status");
Number cnt = (Number) row.get("cnt");
result.put(status, cnt.intValue());
total += cnt.intValue();
}
result.put("total", total);
return result;
}
@Override
public List<String> queryRollNoList(String rollType, String status) {
return baseMapper.selectRollNoList(rollType, status);
}
private LambdaQueryWrapper<MesRollInfo> buildQueryWrapper(MesRollInfoBo bo) {
LambdaQueryWrapper<MesRollInfo> lqw = Wrappers.lambdaQuery();
lqw.like(StringUtils.isNotBlank(bo.getRollNo()), MesRollInfo::getRollNo, bo.getRollNo());
lqw.eq(StringUtils.isNotBlank(bo.getRollType()), MesRollInfo::getRollType, bo.getRollType());
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), MesRollInfo::getStatus, bo.getStatus());
lqw.orderByAsc(MesRollInfo::getRollType, MesRollInfo::getRollId);
return lqw;
}
@Override
public Long insertByBo(MesRollInfoBo bo) {
MesRollInfo add = BeanUtil.toBean(bo, MesRollInfo.class);
if (StringUtils.isBlank(add.getStatus())) {
add.setStatus("Offline");
}
if (add.getGrindCount() == null) {
add.setGrindCount(0);
}
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setRollId(add.getRollId());
}
return add.getRollId();
}
@Override
public Boolean updateByBo(MesRollInfoBo bo) {
MesRollInfo update = BeanUtil.toBean(bo, MesRollInfo.class);
return baseMapper.updateById(update) > 0;
}
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
return baseMapper.deleteBatchIds(ids) > 0;
}
@Override
public Boolean scrapRoll(Long rollId) {
MesRollInfo current = baseMapper.selectById(rollId);
if (current == null || !"Offline".equals(current.getStatus())) {
throw new RuntimeException("只有离线状态的轧辊才可封闭");
}
MesRollInfo update = new MesRollInfo();
update.setRollId(rollId);
update.setStatus("Scrapped");
return baseMapper.updateById(update) > 0;
}
@Override
public void syncStatusFromChange() {
// 从每个机架最新换辊记录中取出在机辊号,更新为 Online
for (String standNo : Arrays.asList("1#", "2#")) {
MesRollChangeVo latest = rollChangeMapper.selectLatestByStand(standNo);
if (latest == null) continue;
for (String rollNo : Arrays.asList(
latest.getUpperWrNo(), latest.getLowerWrNo(),
latest.getUpperBrNo(), latest.getLowerBrNo())) {
if (StringUtils.isNotBlank(rollNo)) {
baseMapper.updateStatusByRollNo(rollNo, "Online");
}
}
}
}
}

View File

@@ -0,0 +1,85 @@
package com.klp.mes.roll.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.klp.common.utils.StringUtils;
import com.klp.mes.roll.domain.MesRollStandby;
import com.klp.mes.roll.domain.bo.MesRollStandbyBo;
import com.klp.mes.roll.domain.vo.MesRollStandbyVo;
import com.klp.mes.roll.mapper.MesRollInfoMapper;
import com.klp.mes.roll.mapper.MesRollStandbyMapper;
import com.klp.mes.roll.service.IMesRollStandbyService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
/**
* 下批轧辊 Service 实现
*/
@RequiredArgsConstructor
@Service
public class MesRollStandbyServiceImpl implements IMesRollStandbyService {
private final MesRollStandbyMapper baseMapper;
private final MesRollInfoMapper rollInfoMapper;
@Override
public MesRollStandbyVo queryById(Long standbyId) {
return baseMapper.selectVoById(standbyId);
}
@Override
public List<MesRollStandbyVo> queryByStand(String standNo) {
return baseMapper.selectByStand(standNo);
}
@Override
@Transactional(rollbackFor = Exception.class)
public Long addStandby(MesRollStandbyBo bo) {
MesRollStandby add = BeanUtil.toBean(bo, MesRollStandby.class);
if (add.getReadyTime() == null) {
add.setReadyTime(new Date());
}
baseMapper.insert(add);
// 将该辊状态更新为 Standby下批待用
if (StringUtils.isNotBlank(add.getRollNo())) {
rollInfoMapper.updateStatusByRollNo(add.getRollNo(), "Standby");
}
return add.getStandbyId();
}
@Override
public Boolean updateByBo(MesRollStandbyBo bo) {
MesRollStandby update = BeanUtil.toBean(bo, MesRollStandby.class);
return baseMapper.updateById(update) > 0;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean deleteById(Long standbyId) {
MesRollStandbyVo vo = baseMapper.selectVoById(standbyId);
boolean ok = baseMapper.deleteById(standbyId) > 0;
// 只有仍处于 Standby 状态时才回退为 Offline若已换上变 Online 则不干涉)
if (ok && vo != null && StringUtils.isNotBlank(vo.getRollNo())) {
rollInfoMapper.updateStatusByRollNoIfStatus(vo.getRollNo(), "Offline", "Standby");
}
return ok;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean clearByStand(String standNo) {
// 先查出所有辊号再清空
List<MesRollStandbyVo> list = baseMapper.selectByStand(standNo);
int rows = baseMapper.clearByStand(standNo);
for (MesRollStandbyVo vo : list) {
if (StringUtils.isNotBlank(vo.getRollNo())) {
// 只有仍处于 Standby 状态时才回退为 Offline换辊后已变 Online 的不动)
rollInfoMapper.updateStatusByRollNoIfStatus(vo.getRollNo(), "Offline", "Standby");
}
}
return rows > 0;
}
}

View File

@@ -0,0 +1,47 @@
<?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.klp.mes.roll.mapper.MesRollChangeMapper">
<!-- 查询指定机架最新一次换辊记录(即当前在机轧辊) -->
<select id="selectLatestByStand" resultType="com.klp.mes.roll.domain.vo.MesRollChangeVo">
SELECT change_id, change_no, change_time, stand_no, change_type, change_status, operator,
upper_wr_no, upper_wr_dia, lower_wr_no, lower_wr_dia,
upper_br_no, upper_br_dia, lower_br_no, lower_br_dia,
remark, create_time
FROM mes_roll_change
WHERE del_flag = 0
AND stand_no = #{standNo}
ORDER BY change_time DESC, change_id DESC
LIMIT 1
</select>
<!-- 查询同机架在本次换辊之后最近一次换辊的时间 -->
<select id="selectNextChangeTime" resultType="java.util.Date">
SELECT MIN(change_time)
FROM mes_roll_change
WHERE del_flag = 0
AND stand_no = #{standNo}
AND change_time > #{changeTime}
</select>
<!--
统计 [startTime, endTime) 时间段内,
符合条件的 wms_coil_pending_action 记录关联的卷料实测长度之和mm
endTime 为 null 时取 NOW() 作为上界。
processed_coil_ids 存储逗号分隔的 material_id 列表,使用 FIND_IN_SET 关联。
-->
<select id="selectWorkLength" resultType="java.math.BigDecimal">
SELECT IFNULL(SUM(mc.actual_length), 0)
FROM wms_coil_pending_action cpa
INNER JOIN wms_material_coil mc
ON FIND_IN_SET(mc.coil_id, cpa.processed_coil_ids) > 0
WHERE cpa.del_flag = 0
AND cpa.action_status = 2
AND cpa.action_type IN (205, 504, 524)
AND cpa.create_time &gt;= #{startTime}
AND cpa.create_time &lt; IFNULL(#{endTime}, NOW())
AND mc.create_time &gt;= #{startTime}
AND mc.create_time &lt; IFNULL(#{endTime}, NOW())
</select>
</mapper>

View File

@@ -0,0 +1,45 @@
<?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.klp.mes.roll.mapper.MesRollInfoMapper">
<select id="selectStatusStats" resultType="map">
SELECT status, COUNT(*) AS cnt
FROM mes_roll_info
WHERE del_flag = 0
GROUP BY status
</select>
<select id="selectRollNoList" resultType="string">
SELECT roll_no FROM mes_roll_info
WHERE del_flag = 0
AND status != 'Scrapped'
<if test="rollType != null and rollType != ''">
AND roll_type = #{rollType}
</if>
<if test="status != null and status != ''">
AND status = #{status}
</if>
ORDER BY roll_no ASC
</select>
<select id="selectByRollNo" resultType="com.klp.mes.roll.domain.MesRollInfo">
SELECT * FROM mes_roll_info
WHERE del_flag = 0 AND roll_no = #{rollNo}
LIMIT 1
</select>
<update id="updateStatusByRollNo">
UPDATE mes_roll_info
SET status = #{status}, update_time = NOW()
WHERE del_flag = 0 AND roll_no = #{rollNo}
</update>
<update id="updateStatusByRollNoIfStatus">
UPDATE mes_roll_info
SET status = #{status}, update_time = NOW()
WHERE del_flag = 0 AND roll_no = #{rollNo} AND status = #{onlyIfStatus}
</update>
</mapper>

View File

@@ -0,0 +1,33 @@
<?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.klp.mes.roll.mapper.MesRollStandbyMapper">
<!-- 按机架查询下批轧辊,附带辊位中文标签 -->
<select id="selectByStand" resultType="com.klp.mes.roll.domain.vo.MesRollStandbyVo">
SELECT
standby_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}
ORDER BY
FIELD(roll_type, 'BR', 'WR', 'WR', 'BR'),
FIELD(position, 'UP', 'UP', 'DOWN', 'DOWN')
</select>
<!-- 逻辑删除指定机架所有下批轧辊(清空) -->
<update id="clearByStand">
UPDATE mes_roll_standby
SET del_flag = 1
WHERE del_flag = 0
AND stand_no = #{standNo}
</update>
</mapper>

View File

@@ -0,0 +1,62 @@
import request from '@/utils/request'
// 查询换辊记录分页列表(支持按机架、类型、时间筛选)
export function listRollChange(query) {
return request({
url: '/mes/rollChange/list',
method: 'get',
params: query
})
}
// 查询指定机架当前在机轧辊(最近一次换辊记录)
export function getCurrentRolls(standNo) {
return request({
url: '/mes/rollChange/current',
method: 'get',
params: { standNo }
})
}
// 查询指定机架当前轧辊实时工作长度m
export function getWorkLength(standNo) {
return request({
url: '/mes/rollChange/workLength',
method: 'get',
params: { standNo }
})
}
// 查询换辊记录详细
export function getRollChange(changeId) {
return request({
url: '/mes/rollChange/' + changeId,
method: 'get'
})
}
// 新增换辊记录(自动同步辊状态为 Online
export function addRollChange(data) {
return request({
url: '/mes/rollChange',
method: 'post',
data: data
})
}
// 修改换辊记录
export function updateRollChange(data) {
return request({
url: '/mes/rollChange',
method: 'put',
data: data
})
}
// 删除换辊记录
export function delRollChange(changeIds) {
return request({
url: '/mes/rollChange/' + changeIds,
method: 'delete'
})
}

View File

@@ -0,0 +1,87 @@
import request from '@/utils/request'
// 查询轧辊库分页列表
export function listRollInfo(query) {
return request({
url: '/mes/rollInfo/list',
method: 'get',
params: query
})
}
// 查询状态统计卡片
export function getRollStats() {
return request({
url: '/mes/rollInfo/stats',
method: 'get'
})
}
// 查询轧辊编号下拉rollType/status 均可为空,不传则不过滤)
export function listRollOptions(rollType, status) {
return request({
url: '/mes/rollInfo/options',
method: 'get',
params: { rollType, status }
})
}
// 查询轧辊详细
export function getRollInfo(rollId) {
return request({
url: '/mes/rollInfo/' + rollId,
method: 'get'
})
}
// 新增轧辊
export function addRollInfo(data) {
return request({
url: '/mes/rollInfo',
method: 'post',
data: data
})
}
// 修改轧辊
export function updateRollInfo(data) {
return request({
url: '/mes/rollInfo',
method: 'put',
data: data
})
}
// 删除轧辊(仅报废状态可删)
export function delRollInfo(rollIds) {
return request({
url: '/mes/rollInfo/' + rollIds,
method: 'delete'
})
}
// 封闭轧辊(→报废)
export function scrapRollInfo(rollId) {
return request({
url: '/mes/rollInfo/' + rollId + '/scrap',
method: 'put'
})
}
// 从换辊记录同步在线状态
export function syncRollStatus() {
return request({
url: '/mes/rollInfo/syncStatus',
method: 'post'
})
}
// 导出轧辊
export function exportRollInfo(query) {
return request({
url: '/mes/rollInfo/export',
method: 'post',
params: query,
responseType: 'blob'
})
}

View File

@@ -0,0 +1,53 @@
import request from '@/utils/request'
// 查询指定机架下批轧辊列表
export function listRollStandby(standNo) {
return request({
url: '/mes/rollStandby/list',
method: 'get',
params: { standNo }
})
}
// 查询下批轧辊详细
export function getRollStandby(standbyId) {
return request({
url: '/mes/rollStandby/' + standbyId,
method: 'get'
})
}
// 新增下批轧辊(自动同步辊状态为 Standby
export function addRollStandby(data) {
return request({
url: '/mes/rollStandby',
method: 'post',
data: data
})
}
// 修改下批轧辊
export function updateRollStandby(data) {
return request({
url: '/mes/rollStandby',
method: 'put',
data: data
})
}
// 删除单条下批轧辊(自动恢复辊状态为 Offline
export function delRollStandby(standbyId) {
return request({
url: '/mes/rollStandby/' + standbyId,
method: 'delete'
})
}
// 清空指定机架全部下批轧辊
export function clearRollStandby(standNo) {
return request({
url: '/mes/rollStandby/clear',
method: 'delete',
params: { standNo }
})
}

View File

@@ -8,8 +8,8 @@
<div class="el-table-container" ref="elTableWrapper" @mouseleave="handleTableLeave"> <div class="el-table-container" ref="elTableWrapper" @mouseleave="handleTableLeave">
<!-- 原生 Table 核心透传 props/事件/插槽 --> <!-- 原生 Table 核心透传 props/事件/插槽 -->
<el-table :ref="tableRef" v-bind="$attrs" v-on="$listeners" :class="['my-table', customClass]" <el-table :ref="tableRef" v-bind="tableAttrs" v-on="$listeners" :class="['my-table', customClass]"
@cell-mouse-enter="handleCellEnter" @row-mouseleave="handleRowLeave" :height="height"> @cell-mouse-enter="handleCellEnter" @row-mouseleave="handleRowLeave">
<!-- 2. 透传原生内置插槽 empty 空数据插槽append 底部插槽等 --> <!-- 2. 透传原生内置插槽 empty 空数据插槽append 底部插槽等 -->
<template v-slot:empty="scope"> <template v-slot:empty="scope">
<slot name="empty" v-bind="scope"></slot> <slot name="empty" v-bind="scope"></slot>
@@ -102,6 +102,13 @@ export default {
}; };
}, },
computed: { computed: {
tableAttrs() {
const attrs = { ...this.$attrs }
if (this.height !== '' && this.height !== null && this.height !== undefined) {
attrs.height = this.height
}
return attrs
},
floatLayerColumns() { floatLayerColumns() {
if (this.floatLayerConfig?.columns?.length > 1) { if (this.floatLayerConfig?.columns?.length > 1) {
return this.floatLayerConfig.columns return this.floatLayerConfig.columns

View File

@@ -1,5 +1,5 @@
<template> <template>
<div :class="{'hidden':hidden}" class="pagination-container" :style="style"> <div :class="{'hidden':hidden}" class="pagination-container" :style="containerStyle">
<el-pagination <el-pagination
:background="background" :background="background"
:current-page.sync="currentPage" :current-page.sync="currentPage"
@@ -61,7 +61,7 @@ export default {
type: Boolean, type: Boolean,
default: false default: false
}, },
style: { containerStyle: {
type: String, type: String,
default: '' default: ''
} }

View File

@@ -0,0 +1,469 @@
<template>
<div class="app-container roll-overview">
<!-- 状态统计看板 -->
<div class="stat-panel mb16">
<div class="stat-item">
<div class="stat-icon-wrap total-icon"><i class="el-icon-data-line" /></div>
<div class="stat-body">
<div class="stat-num">{{ stats.total || 0 }}</div>
<div class="stat-label">轧辊总数</div>
</div>
<div class="stat-divider" />
</div>
<div class="stat-item">
<div class="stat-icon-wrap online-icon"><i class="el-icon-circle-check" /></div>
<div class="stat-body">
<div class="stat-num online-num">{{ stats.Online || 0 }}</div>
<div class="stat-label"> 线</div>
</div>
<div class="stat-divider" />
</div>
<div class="stat-item">
<div class="stat-icon-wrap standby-icon"><i class="el-icon-time" /></div>
<div class="stat-body">
<div class="stat-num standby-num">{{ stats.Standby || 0 }}</div>
<div class="stat-label"> </div>
</div>
<div class="stat-divider" />
</div>
<div class="stat-item">
<div class="stat-icon-wrap offline-icon"><i class="el-icon-remove-outline" /></div>
<div class="stat-body">
<div class="stat-num offline-num">{{ stats.Offline || 0 }}</div>
<div class="stat-label"> 线</div>
</div>
<div class="stat-divider" />
</div>
<div class="stat-item">
<div class="stat-icon-wrap scrapped-icon"><i class="el-icon-warning-outline" /></div>
<div class="stat-body">
<div class="stat-num scrapped-num">{{ stats.Scrapped || 0 }}</div>
<div class="stat-label"> </div>
</div>
</div>
</div>
<!-- 搜索栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="轧辊编号" prop="rollNo">
<el-input v-model="queryParams.rollNo" placeholder="请输入轧辊编号" clearable @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="辊型" prop="rollType">
<el-select v-model="queryParams.rollType" placeholder="全部" clearable style="width:120px">
<el-option label="工作辊 WR" value="WR" />
<el-option label="支撑辊 BR" value="BR" />
</el-select>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="全部" clearable style="width:130px">
<el-option label="在线" value="Online" />
<el-option label="备用" value="Standby" />
<el-option label="离线" value="Offline" />
<el-option label="报废" value="Scrapped" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<!-- 操作按钮 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="info" plain icon="el-icon-refresh" size="mini" @click="handleSyncStatus">同步在线状态</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" />
</el-row>
<!-- 数据表格 -->
<KLPTable v-loading="loading" :data="rollList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="轧辊编号" align="center" prop="rollNo" min-width="130">
<template slot-scope="scope">
<span class="roll-no-text">{{ scope.row.rollNo }}</span>
</template>
</el-table-column>
<el-table-column label="辊型" align="center" prop="rollType" width="100">
<template slot-scope="scope">
<span :class="['roll-type-tag', scope.row.rollType === 'WR' ? 'wr-tag' : 'br-tag']">
{{ scope.row.rollType === 'WR' ? '工作辊 WR' : '支撑辊 BR' }}
</span>
</template>
</el-table-column>
<el-table-column label="状态" align="center" prop="status" width="90">
<template slot-scope="scope">
<span :class="['status-dot-wrap', 'status-' + scope.row.status]">
<span class="status-dot" />
{{ statusLabel(scope.row.status) }}
</span>
</template>
</el-table-column>
<el-table-column label="初始直径(mm)" align="right" prop="initialDia" width="120" />
<el-table-column label="当前直径(mm)" align="right" prop="currentDia" width="120">
<template slot-scope="scope">
<span :class="{ 'warn-text': isDiaLow(scope.row) }">{{ scope.row.currentDia }}</span>
</template>
</el-table-column>
<el-table-column label="最小直径(mm)" align="right" prop="minDia" width="120" />
<el-table-column label="粗糙度" align="right" prop="roughness" width="90" />
<el-table-column label="凸度" align="right" prop="crown" width="90" />
<el-table-column label="材质" align="center" prop="material" width="100" />
<el-table-column label="磨削次数" align="center" prop="grindCount" width="90" />
<el-table-column label="累计轧制量(t)" align="right" prop="totalRolledWeight" width="130" />
<el-table-column label="制造日期" align="center" prop="manufactureDate" width="110" />
<el-table-column label="备注" align="left" prop="remark" min-width="120" show-overflow-tooltip />
<el-table-column label="操作" align="center" width="160" fixed="right">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">修改</el-button>
<el-button v-if="scope.row.status === 'Offline'" size="mini" type="text"
class="scrap-btn" icon="el-icon-lock" @click="handleScrap(scope.row)">封闭</el-button>
<el-button v-if="scope.row.status === 'Scrapped'" size="mini" type="text"
class="del-btn" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</KLPTable>
<!-- 分页 -->
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
<!-- 新增/修改对话框 -->
<el-dialog :title="title" :visible.sync="open" width="620px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="110px">
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="轧辊编号" prop="rollNo">
<el-input v-model="form.rollNo" placeholder="请输入轧辊编号" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="辊型" prop="rollType">
<el-select v-model="form.rollType" placeholder="请选择辊型" style="width:100%">
<el-option label="工作辊 WR" value="WR" />
<el-option label="支撑辊 BR" value="BR" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="初始直径(mm)" prop="initialDia">
<el-input-number v-model="form.initialDia" :precision="2" :min="0" style="width:100%" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="当前直径(mm)" prop="currentDia">
<el-input-number v-model="form.currentDia" :precision="2" :min="0" style="width:100%" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="最小直径(mm)" prop="minDia">
<el-input-number v-model="form.minDia" :precision="2" :min="0" style="width:100%" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="材质" prop="material">
<el-input v-model="form.material" placeholder="请输入材质" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="粗糙度" prop="roughness">
<el-input-number v-model="form.roughness" :precision="4" :min="0" style="width:100%" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="凸度" prop="crown">
<el-input-number v-model="form.crown" :precision="4" style="width:100%" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="制造日期" prop="manufactureDate">
<el-date-picker v-model="form.manufactureDate" type="date" value-format="yyyy-MM-dd"
placeholder="请选择制造日期" style="width:100%" />
</el-form-item>
</el-col>
<el-col :span="12" v-if="!form.rollId">
<el-form-item label="状态">
<el-input value="离线" readonly style="width:100%" />
</el-form-item>
</el-col>
</el-row>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" :rows="2" placeholder="请输入备注" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listRollInfo, getRollStats, getRollInfo, addRollInfo, updateRollInfo, delRollInfo, scrapRollInfo, syncRollStatus } from '@/api/mes/roll/rollInfo'
export default {
name: 'RollOverview',
data() {
return {
loading: false,
showSearch: true,
single: true,
multiple: true,
total: 0,
rollList: [],
stats: {},
title: '',
open: false,
queryParams: {
pageNum: 1,
pageSize: 20,
rollNo: undefined,
rollType: undefined,
status: undefined
},
form: {},
rules: {
rollNo: [{ required: true, message: '轧辊编号不能为空', trigger: 'blur' }],
rollType: [{ required: true, message: '请选择辊型', trigger: 'change' }]
},
ids: []
}
},
created() {
this.getStats()
this.getList()
},
methods: {
getList() {
this.loading = true
listRollInfo(this.queryParams).then(res => {
this.rollList = res.rows
this.total = res.total
this.loading = false
}).catch(() => { this.loading = false })
},
getStats() {
getRollStats().then(res => { this.stats = res.data || {} })
},
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
resetQuery() {
this.resetForm('queryForm')
this.handleQuery()
},
handleSelectionChange(selection) {
this.ids = selection.map(item => item.rollId)
this.single = selection.length !== 1
this.multiple = !selection.length
},
handleAdd() {
this.reset()
this.title = '新增轧辊'
this.open = true
},
handleUpdate(row) {
this.reset()
const rollId = row ? row.rollId : this.ids[0]
getRollInfo(rollId).then(res => {
this.form = res.data
this.title = '修改轧辊'
this.open = true
})
},
handleDelete(row) {
const rollIds = row ? [row.rollId] : this.ids
this.$modal.confirm('确认删除该报废轧辊记录?此操作不可恢复。').then(() => {
return delRollInfo(rollIds.join(','))
}).then(() => {
this.getList()
this.getStats()
this.$modal.msgSuccess('删除成功')
})
},
handleScrap(row) {
this.$modal.confirm('确认封闭轧辊【' + row.rollNo + '】?封闭后状态将变为报废,不可恢复。').then(() => {
return scrapRollInfo(row.rollId)
}).then(() => {
this.getList()
this.getStats()
this.$modal.msgSuccess('封闭成功')
})
},
handleSyncStatus() {
this.$modal.confirm('将从换辊记录中重新推算各机架当前在机轧辊的状态,确认执行?').then(() => {
return syncRollStatus()
}).then(() => {
this.getList()
this.getStats()
this.$modal.msgSuccess('状态同步完成')
})
},
handleExport() {
this.download('/mes/rollInfo/export', this.queryParams, '轧辊数据.xlsx')
},
submitForm() {
this.$refs.form.validate(valid => {
if (!valid) return
const action = this.form.rollId ? updateRollInfo : addRollInfo
action(this.form).then(() => {
this.$modal.msgSuccess(this.form.rollId ? '修改成功' : '新增成功')
this.open = false
this.getList()
this.getStats()
})
})
},
cancel() {
this.open = false
this.reset()
},
reset() {
this.form = { status: 'Offline' }
this.resetForm('form')
},
statusLabel(status) {
const map = { Online: '在线', Standby: '备用', Offline: '离线', Scrapped: '报废' }
return map[status] || status
},
// 当前直径接近最小直径时高亮警告
isDiaLow(row) {
if (!row.currentDia || !row.minDia) return false
return Number(row.currentDia) - Number(row.minDia) < 5
}
}
}
</script>
<style scoped>
/* ─── 调色板(金属灰工业风) ─────────────────────────────────── */
/* 主背景 #f4f5f7 卡片底 #fff 边框 #dcdee0 文字主 #1f2329 文字副 #646a73 */
/* 在线=深绿 #0a7c42 备用=深琥珀 #8b5c00 离线=钢灰 #5f6368 报废=深红 #a61c00 */
.roll-overview { background: #f4f5f7; }
.mb16 { margin-bottom: 16px; }
/* ─── 统计看板 ──────────────────────────────────────────────── */
.stat-panel {
display: flex;
background: #fff;
border: 1px solid #dcdee0;
border-radius: 4px;
padding: 0;
overflow: hidden;
}
.stat-item {
flex: 1;
display: flex;
align-items: center;
padding: 18px 20px;
gap: 14px;
position: relative;
}
.stat-divider {
position: absolute;
right: 0; top: 16px; bottom: 16px;
width: 1px;
background: #e4e6ea;
}
.stat-icon-wrap {
width: 42px; height: 42px;
border-radius: 4px;
display: flex; align-items: center; justify-content: center;
font-size: 20px;
flex-shrink: 0;
}
.total-icon { background: #edf0f3; color: #3d4b5c; }
.online-icon { background: #e8f5ef; color: #0a7c42; }
.standby-icon { background: #fdf3e3; color: #8b5c00; }
.offline-icon { background: #f0f1f2; color: #5f6368; }
.scrapped-icon { background: #fdecea; color: #a61c00; }
.stat-body { display: flex; flex-direction: column; }
.stat-num {
font-size: 26px;
font-weight: 700;
line-height: 1;
color: #1f2329;
font-variant-numeric: tabular-nums;
letter-spacing: -0.5px;
}
.online-num { color: #0a7c42; }
.standby-num { color: #8b5c00; }
.offline-num { color: #5f6368; }
.scrapped-num { color: #a61c00; }
.stat-label {
font-size: 12px;
color: #8f9099;
margin-top: 4px;
letter-spacing: 1px;
}
/* ─── 表格内样式 ─────────────────────────────────────────────── */
.roll-no-text {
font-family: 'Consolas', 'Courier New', monospace;
font-weight: 600;
color: #1f2329;
letter-spacing: .3px;
}
/* 辊型标签 */
.roll-type-tag {
display: inline-block;
padding: 1px 8px;
border-radius: 2px;
font-size: 11px;
font-weight: 600;
letter-spacing: .3px;
}
.wr-tag { background: #e8edf5; color: #2b4c8c; border: 1px solid #c5d0e8; }
.br-tag { background: #f0eae0; color: #6b4c1e; border: 1px solid #dccfb8; }
/* 状态指示 */
.status-dot-wrap {
display: inline-flex; align-items: center; gap: 5px;
font-size: 12px; font-weight: 500;
}
.status-dot {
width: 7px; height: 7px;
border-radius: 50%;
display: inline-block;
flex-shrink: 0;
}
.status-Online { color: #0a7c42; }
.status-Online .status-dot { background: #0a7c42; box-shadow: 0 0 0 2px #c8ead8; }
.status-Standby { color: #8b5c00; }
.status-Standby .status-dot { background: #d4860a; box-shadow: 0 0 0 2px #f5e2b8; }
.status-Offline { color: #5f6368; }
.status-Offline .status-dot { background: #9aa0a6; box-shadow: 0 0 0 2px #e0e2e4; }
.status-Scrapped { color: #a61c00; }
.status-Scrapped .status-dot { background: #c5221f; box-shadow: 0 0 0 2px #f5c6c4; }
/* 直径接近下限警告 */
.warn-text { color: #a61c00; font-weight: 600; }
/* 封闭按钮 */
.scrap-btn { color: #8b5c00 !important; }
/* 删除按钮单独着色 */
.del-btn { color: #c5221f !important; }
</style>

View File

@@ -0,0 +1,852 @@
<template>
<div class="app-container working-roll-page">
<!-- 顶部行作业辊一览2/3+ 可用轧辊1/3 -->
<div class="top-row">
<!-- 作业辊一览 -->
<el-card shadow="never" class="roll-table-card top-row__main">
<div slot="header" class="card-header">
<span class="card-title"><i class="el-icon-s-grid" /> 作业辊一览</span>
<span class="header-meta" v-if="current['1#'] && current['1#'].changeTime">
1# 末次换辊{{ current['1#'].changeTime }}
</span>
<span class="header-meta" v-if="current['2#'] && current['2#'].changeTime">
&nbsp;·&nbsp;2# 末次换辊{{ current['2#'].changeTime }}
</span>
<span style="margin-left:auto;display:flex;align-items:center;gap:6px;flex-wrap:wrap">
<el-button size="mini" icon="el-icon-refresh-right" @click="handleOpenChange('1#')">1# 换辊</el-button>
<el-button size="mini" icon="el-icon-refresh-right" @click="handleOpenChange('2#')">2# 换辊</el-button>
<el-divider direction="vertical" />
<el-button type="success" size="mini" icon="el-icon-plus" @click="handleAddStandby('1#')">1# 添加下批</el-button>
<el-button type="danger" size="mini" icon="el-icon-delete" @click="handleClearStandby('1#')"
:disabled="!(standbyList['1#'] && standbyList['1#'].length)">1# 清空</el-button>
<el-button type="success" size="mini" icon="el-icon-plus" @click="handleAddStandby('2#')">2# 添加下批</el-button>
<el-button type="danger" size="mini" icon="el-icon-delete" @click="handleClearStandby('2#')"
:disabled="!(standbyList['2#'] && standbyList['2#'].length)">2# 清空</el-button>
</span>
</div>
<el-table
ref="mainTable"
:data="mergedRows"
v-loading="loadingCurrent['1#'] || loadingCurrent['2#'] || loadingStandby['1#'] || loadingStandby['2#']"
:row-class-name="rowClass"
:span-method="mergeParamCol"
border
size="small"
style="width:100%"
>
<el-table-column label="参数" width="126" align="left">
<template slot-scope="scope">
<span :class="['param-label', scope.row.group]">{{ scope.row.label }}</span>
</template>
</el-table-column>
<el-table-column label="当前在机轧辊" align="center">
<el-table-column label="1#" align="center" min-width="88">
<template slot-scope="scope">
<param-cell :data="scope.row.cur1" />
</template>
</el-table-column>
<el-table-column label="2#" align="center" min-width="88">
<template slot-scope="scope">
<param-cell :data="scope.row.cur2" />
</template>
</el-table-column>
</el-table-column>
<el-table-column label="下批轧辊" align="center">
<el-table-column label="1#" align="center" min-width="88">
<template slot-scope="scope">
<div
:class="['sb-cell',
scope.row.sb1 && scope.row.sb1.standbyId ? 'sb-cell--del' :
scope.row.rollType ? 'sb-cell--add' : '']"
@click="handleSbCellClick(scope.row.sb1, '1#', scope.row.rollType, scope.row.position)"
>
<param-cell :data="scope.row.sb1" />
</div>
</template>
</el-table-column>
<el-table-column label="2#" align="center" min-width="88">
<template slot-scope="scope">
<div
:class="['sb-cell',
scope.row.sb2 && scope.row.sb2.standbyId ? 'sb-cell--del' :
scope.row.rollType ? 'sb-cell--add' : '']"
@click="handleSbCellClick(scope.row.sb2, '2#', scope.row.rollType, scope.row.position)"
>
<param-cell :data="scope.row.sb2" />
</div>
</template>
</el-table-column>
</el-table-column>
</el-table>
</el-card>
<!-- 可用轧辊离线 -->
<el-card shadow="never" class="roll-table-card top-row__aside">
<div slot="header" class="card-header">
<span class="card-title"><i class="el-icon-files" /> 可用轧辊离线</span>
<el-button size="mini" icon="el-icon-refresh" style="margin-left:auto" @click="loadOfflineRolls">刷新</el-button>
</div>
<el-table v-loading="offlineLoading" :data="offlineRolls" size="small" :height="asideTableHeight" style="width:100%">
<el-table-column label="辊型" align="center" prop="rollType" width="58">
<template slot-scope="scope">
<el-tag size="mini" :type="scope.row.rollType === 'WR' ? 'primary' : 'warning'">
{{ scope.row.rollType }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="轧辊编号" align="center" prop="rollNo" min-width="110" show-overflow-tooltip />
<el-table-column label="辊径(mm)" align="center" width="82">
<template slot-scope="scope">
{{ scope.row.currentDia != null ? scope.row.currentDia : scope.row.initialDia }}
</template>
</el-table-column>
<el-table-column label="粗糙度" align="center" prop="roughness" width="70" />
<el-table-column label="磨削次数" align="center" prop="grindCount" width="70" />
</el-table>
</el-card>
</div>
<!-- 换辊历史 -->
<el-card shadow="never" class="roll-table-card" style="margin-top:16px">
<div slot="header" class="card-header">
<span class="card-title"><i class="el-icon-document" /> 换辊历史</span>
<el-form :inline="true" size="small" style="margin-left:auto;margin-bottom:0">
<el-form-item label="机架" style="margin-bottom:0">
<el-select v-model="historyQuery.standNo" placeholder="全部" clearable style="width:100px" @change="loadHistory">
<el-option label="1# 机架" value="1#" />
<el-option label="2# 机架" value="2#" />
</el-select>
</el-form-item>
<el-form-item label="类型" style="margin-bottom:0">
<el-select v-model="historyQuery.changeType" placeholder="全部" clearable style="width:110px" @change="loadHistory">
<el-option label="计划换辊" value="计划换辊" />
<el-option label="紧急换辊" value="紧急换辊" />
</el-select>
</el-form-item>
<el-form-item label="时间起" style="margin-bottom:0">
<el-date-picker v-model="historyQuery.changeTime" type="datetime"
value-format="yyyy-MM-dd HH:mm:ss" placeholder="开始时间"
style="width:160px" @change="loadHistory" />
</el-form-item>
</el-form>
</div>
<KLPTable v-loading="historyLoading" :data="historyList">
<el-table-column label="换辊编号" align="center" prop="changeNo" width="130" />
<el-table-column label="机架" align="center" prop="standNo" width="80" />
<el-table-column label="换辊时间" align="center" prop="changeTime" width="160" />
<el-table-column label="类型" align="center" prop="changeType" width="100">
<template slot-scope="scope">
<el-tag size="small" :type="scope.row.changeType === '紧急换辊' ? 'danger' : ''">{{ scope.row.changeType }}</el-tag>
</template>
</el-table-column>
<el-table-column label="操作人" align="center" prop="operator" width="90" />
<el-table-column label="上工作辊" align="center" prop="upperWrNo" width="110" />
<el-table-column label="下工作辊" align="center" prop="lowerWrNo" width="110" />
<el-table-column label="上支撑辊" align="center" prop="upperBrNo" width="110" />
<el-table-column label="下支撑辊" align="center" prop="lowerBrNo" width="110" />
<el-table-column label="工作长度(m)" align="center" prop="workLength" width="110">
<template slot-scope="scope">
<span v-if="scope.row.workLength != null">{{ scope.row.workLength }}</span>
<span v-else style="color:#c0c4cc"></span>
</template>
</el-table-column>
<el-table-column label="备注" align="left" prop="remark" min-width="100" show-overflow-tooltip />
<el-table-column label="操作" align="center" width="110" fixed="right">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleEditHistory(scope.row)">补录</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" style="color:#c5221f"
@click="handleDeleteHistory(scope.row)">删除</el-button>
</template>
</el-table-column>
</KLPTable>
<pagination
v-show="historyTotal > 0"
:total="historyTotal"
:page.sync="historyQuery.pageNum"
:limit.sync="historyQuery.pageSize"
@pagination="loadHistory"
/>
</el-card>
<!-- 换辊确认弹窗纯展示无需填写 -->
<el-dialog :title="changeForm.standNo + ' 机架 — 确认换辊'" :visible.sync="changeOpen" width="420px" append-to-body @close="resetChangeForm">
<div class="roll-preview">
<div class="roll-preview__title">以下轧辊将被换入</div>
<div class="roll-preview__item">
<span class="rp-label">上支撑辊</span>
<span class="rp-val">{{ changeForm.upperBrNo || '—' }}</span>
<span class="rp-dia" v-if="changeForm.upperBrDia">φ{{ changeForm.upperBrDia }} mm</span>
</div>
<div class="roll-preview__item">
<span class="rp-label">上工作辊</span>
<span class="rp-val">{{ changeForm.upperWrNo || '—' }}</span>
<span class="rp-dia" v-if="changeForm.upperWrDia">φ{{ changeForm.upperWrDia }} mm</span>
</div>
<div class="roll-preview__item">
<span class="rp-label">下工作辊</span>
<span class="rp-val">{{ changeForm.lowerWrNo || '—' }}</span>
<span class="rp-dia" v-if="changeForm.lowerWrDia">φ{{ changeForm.lowerWrDia }} mm</span>
</div>
<div class="roll-preview__item">
<span class="rp-label">下支撑辊</span>
<span class="rp-val">{{ changeForm.lowerBrNo || '—' }}</span>
<span class="rp-dia" v-if="changeForm.lowerBrDia">φ{{ changeForm.lowerBrDia }} mm</span>
</div>
</div>
<div class="roll-preview__tip">
换辊时间和操作人将由系统自动记录
</div>
<div slot="footer">
<el-button type="primary" :loading="changeSubmitting" @click="submitChange">确认换辊</el-button>
<el-button @click="changeOpen = false"> </el-button>
</div>
</el-dialog>
<!-- 换辊历史补录/编辑对话框 -->
<el-dialog title="换辊记录补录" :visible.sync="historyEditOpen" width="560px" append-to-body @close="historyEditForm = {}">
<el-form ref="historyEditForm" :model="historyEditForm" label-width="100px" size="small">
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="机架">
<el-input :value="historyEditForm.standNo" readonly />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="换辊类型">
<el-select v-model="historyEditForm.changeType" style="width:100%">
<el-option label="计划换辊" value="计划换辊" />
<el-option label="紧急换辊" value="紧急换辊" />
<el-option label="三级换辊" value="三级换辊" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="换辊时间">
<el-date-picker v-model="historyEditForm.changeTime" type="datetime"
value-format="yyyy-MM-dd HH:mm:ss" style="width:100%" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="操作人">
<el-input v-model="historyEditForm.operator" />
</el-form-item>
</el-col>
</el-row>
<el-divider content-position="left">工作辊</el-divider>
<el-row :gutter="16">
<el-col :span="12"><el-form-item label="上工作辊"><el-input v-model="historyEditForm.upperWrNo" /></el-form-item></el-col>
<el-col :span="12"><el-form-item label="上工作辊径"><el-input-number v-model="historyEditForm.upperWrDia" :precision="2" :min="0" style="width:100%" /></el-form-item></el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12"><el-form-item label="下工作辊"><el-input v-model="historyEditForm.lowerWrNo" /></el-form-item></el-col>
<el-col :span="12"><el-form-item label="下工作辊径"><el-input-number v-model="historyEditForm.lowerWrDia" :precision="2" :min="0" style="width:100%" /></el-form-item></el-col>
</el-row>
<el-divider content-position="left">支撑辊</el-divider>
<el-row :gutter="16">
<el-col :span="12"><el-form-item label="上支撑辊"><el-input v-model="historyEditForm.upperBrNo" /></el-form-item></el-col>
<el-col :span="12"><el-form-item label="上支撑辊径"><el-input-number v-model="historyEditForm.upperBrDia" :precision="2" :min="0" style="width:100%" /></el-form-item></el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12"><el-form-item label="下支撑辊"><el-input v-model="historyEditForm.lowerBrNo" /></el-form-item></el-col>
<el-col :span="12"><el-form-item label="下支撑辊径"><el-input-number v-model="historyEditForm.lowerBrDia" :precision="2" :min="0" style="width:100%" /></el-form-item></el-col>
</el-row>
<el-form-item label="备注">
<el-input v-model="historyEditForm.remark" type="textarea" :rows="2" />
</el-form-item>
</el-form>
<div slot="footer">
<el-button type="primary" @click="submitHistoryEdit"> </el-button>
<el-button @click="historyEditOpen = false"> </el-button>
</div>
</el-dialog>
<!-- 添加下批轧辊对话框 -->
<el-dialog title="添加下批轧辊" :visible.sync="standbyOpen" width="460px" append-to-body @close="resetStandbyForm">
<el-form ref="standbyForm" :model="standbyForm" :rules="standbyRules" label-width="100px">
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="机架" prop="standNo">
<el-select v-model="standbyForm.standNo" style="width:100%" :disabled="standbyFromCell">
<el-option label="1# 机架" value="1#" />
<el-option label="2# 机架" value="2#" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="辊型" prop="rollType">
<el-input
v-if="standbyFromCell"
:value="standbyForm.rollType === 'WR' ? '工作辊 WR' : '支撑辊 BR'"
readonly style="width:100%"
/>
<el-select v-else v-model="standbyForm.rollType" placeholder="请选择" style="width:100%"
@change="handleStandbyRollTypeChange">
<el-option label="工作辊 WR" value="WR" />
<el-option label="支撑辊 BR" value="BR" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="辊位" prop="position">
<el-input
v-if="standbyFromCell"
:value="standbyForm.position === 'UP' ? '上辊' : '下辊'"
readonly style="width:100%"
/>
<el-select v-else v-model="standbyForm.position" placeholder="请选择" style="width:100%">
<el-option label="上辊" value="UP" />
<el-option label="下辊" value="DOWN" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="轧辊编号" prop="rollNo">
<el-select v-model="standbyForm.rollNo" placeholder="请选择" filterable style="width:100%">
<el-option
v-for="no in standbyForm.rollType === 'WR' ? wrOptions : brOptions"
:key="no" :label="no" :value="no"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="就绪时间">
<el-date-picker v-model="standbyForm.readyTime" type="datetime"
value-format="yyyy-MM-dd HH:mm:ss" placeholder="默认当前时间" style="width:100%" />
</el-form-item>
<el-form-item label="备注">
<el-input v-model="standbyForm.remark" type="textarea" :rows="2" />
</el-form-item>
</el-form>
<div slot="footer">
<el-button type="primary" @click="submitStandby"> </el-button>
<el-button @click="standbyOpen = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { getCurrentRolls, listRollChange, addRollChange, updateRollChange, delRollChange, getWorkLength } from '@/api/mes/roll/rollChange'
import { listRollStandby, addRollStandby, delRollStandby, clearRollStandby } from '@/api/mes/roll/rollStandby'
import { listRollOptions, listRollInfo } from '@/api/mes/roll/rollInfo'
/**
* 单元格组件:只显示数值,不展示辊号副文本和删除图标
* 删除逻辑由外层 div 的 click 事件处理,保证所有单元格高度一致
*/
const ParamCell = {
name: 'ParamCell',
props: {
data: { type: Object, default: null }
},
render(h) {
const d = this.data
if (!d || d.val == null || d.val === '') {
return h('span', { class: 'cell-empty' }, '—')
}
return h('span', { class: 'cell-main' }, String(d.val))
}
}
export default {
name: 'WorkingRoll',
components: { ParamCell },
data() {
return {
current: { '1#': {}, '2#': {} },
loadingCurrent: { '1#': false, '2#': false },
standbyList: { '1#': [], '2#': [] },
loadingStandby: { '1#': false, '2#': false },
/** 当前在机轧辊实时工作长度m */
workLength: { '1#': null, '2#': null },
rollInfoMap: {},
historyLoading: false,
historyList: [],
historyTotal: 0,
historyQuery: { pageNum: 1, pageSize: 15, standNo: undefined, changeType: undefined, changeTime: undefined },
wrOptions: [],
brOptions: [],
historyEditOpen: false,
historyEditForm: {},
offlineRolls: [],
offlineLoading: false,
asideTableHeight: 400,
changeOpen: false,
changeSubmitting: false,
changeForm: this.getDefaultChangeForm(),
standbyOpen: false,
standbyForm: this.getDefaultStandbyForm(),
standbyFromCell: false,
standbyRules: {
standNo: [{ required: true, message: '请选择机架', trigger: 'change' }],
rollType: [{ required: true, message: '请选择辊型', trigger: 'change' }],
position: [{ required: true, message: '请选择辊位', trigger: 'change' }],
rollNo: [{ required: true, message: '请选择轧辊编号', trigger: 'change' }]
}
}
},
computed: {
mergedRows() {
const c1 = this.current['1#'] || {}
const c2 = this.current['2#'] || {}
const ri = this.rollInfoMap
// 当前辊:值来自换辊记录,凸度/粗糙度/材质从 rollInfoMap 查
const cv = (val, rollNo) => ({
val: (val == null || val === '') ? null : val,
sub: rollNo || null
})
const rv = (rollNo, field) => {
const info = rollNo ? ri[rollNo] : null
const val = info ? info[field] : null
return { val: (val == null || val === '') ? null : val, sub: rollNo || null }
}
// 下批辊:优先取 standby 记录自身字段,为空则从 rollInfoMap 读diameter 对应 currentDia
const sv = (standNo, rollType, pos, field) => {
const item = (this.standbyList[standNo] || []).find(
i => i.rollType === rollType && i.position === pos
)
if (!item) return { val: null, sub: null }
let val = item[field]
if ((val == null || val === '') && item.rollNo) {
const info = ri[item.rollNo]
if (info) {
val = field === 'diameter'
? (info.currentDia != null ? info.currentDia : info.initialDia)
: info[field]
}
}
return { val: (val == null || val === '') ? null : val, sub: item.rollNo, standbyId: item.standbyId }
}
const sm = (standNo, rollType, pos) => {
const item = (this.standbyList[standNo] || []).find(
i => i.rollType === rollType && i.position === pos
)
if (!item || !item.rollNo) return { val: null, sub: null }
const info = ri[item.rollNo]
return {
val: info ? (info.material || null) : null,
sub: item.rollNo,
standbyId: item.standbyId
}
}
return [
{
label: '上支承辊直径(mm)', group: 'br', rollType: 'BR', position: 'UP',
cur1: cv(c1.upperBrDia, c1.upperBrNo), cur2: cv(c2.upperBrDia, c2.upperBrNo),
sb1: sv('1#', 'BR', 'UP', 'diameter'), sb2: sv('2#', 'BR', 'UP', 'diameter')
},
{
label: '上工作辊直径(mm)', group: 'wr', rollType: 'WR', position: 'UP',
cur1: cv(c1.upperWrDia, c1.upperWrNo), cur2: cv(c2.upperWrDia, c2.upperWrNo),
sb1: sv('1#', 'WR', 'UP', 'diameter'), sb2: sv('2#', 'WR', 'UP', 'diameter')
},
{
label: '上工作辊凸度', group: 'wr', rollType: 'WR', position: 'UP',
cur1: rv(c1.upperWrNo, 'crown'), cur2: rv(c2.upperWrNo, 'crown'),
sb1: sv('1#', 'WR', 'UP', 'crown'), sb2: sv('2#', 'WR', 'UP', 'crown')
},
{
label: '上工作辊粗糙度(μm)', group: 'wr', rollType: 'WR', position: 'UP',
cur1: rv(c1.upperWrNo, 'roughness'), cur2: rv(c2.upperWrNo, 'roughness'),
sb1: sv('1#', 'WR', 'UP', 'roughness'), sb2: sv('2#', 'WR', 'UP', 'roughness')
},
{
label: '工作辊类型', group: 'wr', rollType: 'WR', position: 'UP',
cur1: rv(c1.upperWrNo, 'material'), cur2: rv(c2.upperWrNo, 'material'),
sb1: sm('1#', 'WR', 'UP'), sb2: sm('2#', 'WR', 'UP')
},
{
label: '下工作辊直径(mm)', group: 'wr', rollType: 'WR', position: 'DOWN',
cur1: cv(c1.lowerWrDia, c1.lowerWrNo), cur2: cv(c2.lowerWrDia, c2.lowerWrNo),
sb1: sv('1#', 'WR', 'DOWN', 'diameter'), sb2: sv('2#', 'WR', 'DOWN', 'diameter')
},
{
label: '下工作辊凸度', group: 'wr', rollType: 'WR', position: 'DOWN',
cur1: rv(c1.lowerWrNo, 'crown'), cur2: rv(c2.lowerWrNo, 'crown'),
sb1: sv('1#', 'WR', 'DOWN', 'crown'), sb2: sv('2#', 'WR', 'DOWN', 'crown')
},
{
label: '下工作辊粗糙度(μm)', group: 'wr', rollType: 'WR', position: 'DOWN',
cur1: rv(c1.lowerWrNo, 'roughness'), cur2: rv(c2.lowerWrNo, 'roughness'),
sb1: sv('1#', 'WR', 'DOWN', 'roughness'), sb2: sv('2#', 'WR', 'DOWN', 'roughness')
},
{
label: '下支承辊直径(mm)', group: 'br', rollType: 'BR', position: 'DOWN',
cur1: cv(c1.lowerBrDia, c1.lowerBrNo), cur2: cv(c2.lowerBrDia, c2.lowerBrNo),
sb1: sv('1#', 'BR', 'DOWN', 'diameter'), sb2: sv('2#', 'BR', 'DOWN', 'diameter')
},
{
label: '轧线设定(mm)', group: 'pl', rollType: null, position: null,
cur1: { val: null, sub: null }, cur2: { val: null, sub: null },
sb1: { val: null, sub: null }, sb2: { val: null, sub: null }
},
{
label: '轧线位置(mm)', group: 'pl', rollType: null, position: null,
cur1: { val: null, sub: null }, cur2: { val: null, sub: null },
sb1: { val: null, sub: null }, sb2: { val: null, sub: null }
},
{
label: '工作长度(m)', group: 'pl', rollType: null, position: null,
cur1: { val: this.workLength['1#'] }, cur2: { val: this.workLength['2#'] },
sb1: { val: null }, sb2: { val: null }
}
]
}
},
created() {
this.loadAll()
this.loadRollOptions()
this.loadRollInfoMap()
},
mounted() {
this.$nextTick(this.syncAsideHeight)
window.addEventListener('resize', this.syncAsideHeight)
},
beforeDestroy() {
window.removeEventListener('resize', this.syncAsideHeight)
},
methods: {
getDefaultChangeForm(standNo) {
return {
standNo: standNo || undefined,
changeType: undefined,
changeTime: undefined,
operator: undefined,
upperWrNo: undefined,
upperWrDia: undefined,
lowerWrNo: undefined,
lowerWrDia: undefined,
upperBrNo: undefined,
upperBrDia: undefined,
lowerBrNo: undefined,
lowerBrDia: undefined,
remark: undefined
}
},
getDefaultStandbyForm(standNo, rollType, position) {
return {
standNo: standNo || undefined,
rollType: rollType || undefined,
position: position || undefined,
rollNo: undefined,
readyTime: undefined,
remark: undefined
}
},
loadAll() {
;['1#', '2#'].forEach(s => {
this.loadCurrent(s)
this.loadStandby(s)
this.loadWorkLength(s)
})
this.loadHistory()
this.loadOfflineRolls()
},
loadWorkLength(standNo) {
getWorkLength(standNo).then(res => {
this.$set(this.workLength, standNo, res.data != null ? res.data : null)
}).catch(() => {})
},
loadCurrent(standNo) {
this.$set(this.loadingCurrent, standNo, true)
getCurrentRolls(standNo).then(res => {
this.$set(this.current, standNo, res.data || {})
this.$set(this.loadingCurrent, standNo, false)
this.$nextTick(this.syncAsideHeight)
}).catch(() => { this.$set(this.loadingCurrent, standNo, false) })
},
loadStandby(standNo) {
this.$set(this.loadingStandby, standNo, true)
listRollStandby(standNo).then(res => {
this.$set(this.standbyList, standNo, res.data || [])
this.$set(this.loadingStandby, standNo, false)
}).catch(() => { this.$set(this.loadingStandby, standNo, false) })
},
loadHistory() {
this.historyLoading = true
listRollChange(this.historyQuery).then(res => {
this.historyList = res.rows || []
this.historyTotal = res.total || 0
this.historyLoading = false
}).catch(() => { this.historyLoading = false })
},
loadRollOptions() {
// 下批辊选择只显示离线Offline状态的轧辊
listRollOptions('WR', 'Offline').then(res => { this.wrOptions = res.data || [] })
listRollOptions('BR', 'Offline').then(res => { this.brOptions = res.data || [] })
},
loadRollInfoMap() {
listRollInfo({ pageNum: 1, pageSize: 500 }).then(res => {
const map = {}
;(res.rows || []).forEach(r => { map[r.rollNo] = r })
this.rollInfoMap = map
})
},
rowClass({ row }) {
if (row.group === 'br') return 'row-br'
if (row.group === 'pl') return 'row-pl'
return ''
},
// el-table span-method参数列不需要 span其余无特殊合并
mergeParamCol({ columnIndex }) {
if (columnIndex === 0) return [1, 1]
},
// 换辊:自动从下批辊填入辊号和径值
handleOpenChange(standNo) {
const list = this.standbyList[standNo] || []
const ri = this.rollInfoMap
const pick = (rollType, pos) => {
const item = list.find(i => i.rollType === rollType && i.position === pos)
if (!item) return { no: undefined, dia: undefined }
const info = ri[item.rollNo]
const dia = item.diameter != null ? item.diameter
: (info ? (info.currentDia != null ? info.currentDia : info.initialDia) : undefined)
return { no: item.rollNo, dia }
}
const uwr = pick('WR', 'UP')
const lwr = pick('WR', 'DOWN')
const ubr = pick('BR', 'UP')
const lbr = pick('BR', 'DOWN')
this.changeForm = {
...this.getDefaultChangeForm(standNo),
upperWrNo: uwr.no, upperWrDia: uwr.dia,
lowerWrNo: lwr.no, lowerWrDia: lwr.dia,
upperBrNo: ubr.no, upperBrDia: ubr.dia,
lowerBrNo: lbr.no, lowerBrDia: lbr.dia
}
this.changeOpen = true
},
submitChange() {
if (this.changeSubmitting) return
this.changeSubmitting = true
const standNo = this.changeForm.standNo
addRollChange(this.changeForm).then(() => {
this.$modal.msgSuccess('换辊成功')
this.changeOpen = false
clearRollStandby(standNo).finally(() => {
this.loadCurrent(standNo)
this.loadStandby(standNo)
this.loadWorkLength(standNo)
this.loadHistory()
this.loadOfflineRolls()
})
}).finally(() => {
this.changeSubmitting = false
})
},
resetChangeForm() {
this.changeForm = this.getDefaultChangeForm()
this.changeSubmitting = false
},
// 下批轧辊 — 单元格点击(空→新增,有数据→删除)
handleSbCellClick(cell, standNo, rollType, position) {
if (cell && cell.standbyId) {
this.handleDelStandby(cell.standbyId, standNo)
} else if (rollType) {
this.standbyForm = this.getDefaultStandbyForm(standNo, rollType, position)
this.standbyFromCell = true
this.standbyOpen = true
}
},
// 下批轧辊 — 顶部"添加下批"按钮(不预设辊型辊位)
handleAddStandby(standNo) {
this.standbyForm = this.getDefaultStandbyForm(standNo)
this.standbyFromCell = false
this.standbyOpen = true
},
handleStandbyRollTypeChange() {
this.$set(this.standbyForm, 'rollNo', undefined)
},
submitStandby() {
this.$refs.standbyForm.validate(valid => {
if (!valid) return
addRollStandby(this.standbyForm).then(() => {
this.$modal.msgSuccess('已添加到下批轧辊')
this.standbyOpen = false
this.loadStandby(this.standbyForm.standNo)
this.loadRollOptions() // 刷新离线辊下拉(已变为 Standby 的辊不再显示)
this.loadOfflineRolls() // 刷新可用辊面板
})
})
},
resetStandbyForm() {
this.standbyForm = this.getDefaultStandbyForm()
this.standbyFromCell = false
this.$nextTick(() => { this.$refs.standbyForm && this.$refs.standbyForm.clearValidate() })
},
handleDelStandby(standbyId, standNo) {
this.$modal.confirm('确认移除该下批轧辊?移除后该辊状态将恢复为"离线"。').then(() => {
return delRollStandby(standbyId)
}).then(() => {
this.$modal.msgSuccess('已移除')
this.loadStandby(standNo)
this.loadRollOptions()
this.loadOfflineRolls()
})
},
handleClearStandby(standNo) {
this.$modal.confirm('确认清空 ' + standNo + ' 机架的全部下批轧辊?').then(() => {
return clearRollStandby(standNo)
}).then(() => {
this.$modal.msgSuccess('已清空')
this.loadStandby(standNo)
})
},
// ── 换辊历史 补录 / 删除 ──────────────────────────────────
handleEditHistory(row) {
this.historyEditForm = { ...row }
this.historyEditOpen = true
},
submitHistoryEdit() {
updateRollChange(this.historyEditForm).then(() => {
this.$modal.msgSuccess('保存成功')
this.historyEditOpen = false
this.loadHistory()
})
},
handleDeleteHistory(row) {
this.$modal.confirm('确认删除该换辊记录?此操作不可恢复。').then(() => {
return delRollChange(row.changeId)
}).then(() => {
this.$modal.msgSuccess('已删除')
this.loadHistory()
})
},
// ── 可用离线辊列表 ────────────────────────────────────────
loadOfflineRolls() {
this.offlineLoading = true
listRollInfo({ status: 'Offline', pageNum: 1, pageSize: 30 }).then(res => {
this.offlineRolls = res.rows || []
}).finally(() => {
this.offlineLoading = false
})
},
// 让右侧表格高度 = 左侧卡片 body 区域高度
syncAsideHeight() {
const el = this.$refs.mainTable && this.$refs.mainTable.$el
if (!el) return
// el-table 的 $el 就是 .el-table 根节点,取其实际渲染高度
const h = el.offsetHeight
if (h > 0) this.asideTableHeight = h
}
}
}
</script>
<style scoped>
.working-roll-page { background: #f4f5f7; }
.roll-table-card { border: 1px solid #dcdee0; border-radius: 4px; }
/* 顶部两栏布局 */
.top-row {
display: flex;
gap: 12px;
align-items: stretch;
}
.top-row__main { flex: 2; min-width: 0; }
.top-row__aside { flex: 1; min-width: 0; }
.card-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-title { font-size: 13px; font-weight: 600; color: #3d4b5c; white-space: nowrap; }
.header-meta { font-size: 11px; color: #8f9099; white-space: nowrap; }
/* 参数列文字 */
.param-label { font-size: 12px; color: #3d4b5c; }
/* 数值单元格 */
.cell-main { font-family: 'Consolas', 'Courier New', monospace; font-size: 13px; font-weight: 600; color: #1f2329; }
.cell-empty { color: #c0c4cc; font-size: 12px; }
/* 换辊预览卡片 */
.roll-preview { background: #f7f8fa; border: 1px solid #e4e6eb; border-radius: 4px; padding: 10px 12px; }
.roll-preview__title { font-size: 11px; color: #8f9099; margin-bottom: 8px; letter-spacing: .5px; }
.roll-preview__item { display: flex; align-items: center; gap: 6px; padding: 4px 0; }
.rp-label { font-size: 12px; color: #8f9099; width: 56px; flex-shrink: 0; }
.rp-val { font-size: 13px; font-weight: 600; color: #1f2329; font-family: 'Consolas', monospace; flex: 1; }
.rp-dia { font-size: 11px; color: #9aa0a6; }
.roll-preview__tip { font-size: 11px; color: #b0b3bb; margin-top: 10px; text-align: center; }
/* 下批辊单元格容器:填满整个 td有数据时点击删除 */
.sb-cell {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
min-height: 36px;
}
/* 有数据 → 点击删除hover 浅红 */
.sb-cell--del {
cursor: pointer;
}
.sb-cell--del:hover {
background: rgba(198, 40, 40, 0.07);
}
/* 空格子 → 点击新增hover 浅绿 */
.sb-cell--add {
cursor: pointer;
}
.sb-cell--add:hover {
background: rgba(35, 134, 54, 0.07);
}
</style>
<style>
/* 行分组色scoped 无法穿透 el-table 内部) */
.working-roll-page .el-table .row-br > td { background-color: #f7f7f6 !important; }
.working-roll-page .el-table .row-pl > td { background-color: #eef2f8 !important; }
/* 列分组标题加粗区分 */
.working-roll-page .el-table__header th.el-table__cell {
background: #f0f2f5;
color: #3d4b5c;
font-weight: 600;
font-size: 12px;
}
</style>

68
script/sql/mysql/mill.sql Normal file
View File

@@ -0,0 +1,68 @@
-- 轧辊库
CREATE TABLE mes_roll_info (
roll_id BIGINT NOT NULL AUTO_INCREMENT,
roll_no VARCHAR(50) NOT NULL COMMENT '轧辊编号',
roll_type VARCHAR(10) NOT NULL COMMENT '辊型: WR=工作辊 / BR=支撑辊',
status VARCHAR(20) NOT NULL DEFAULT 'Offline' COMMENT 'Online/Standby/Offline/Scrapped',
initial_dia DECIMAL(10,2) COMMENT '初始直径(mm)',
current_dia DECIMAL(10,2) COMMENT '当前直径(mm)',
min_dia DECIMAL(10,2) COMMENT '最小直径(mm)',
roughness DECIMAL(10,4),
crown DECIMAL(10,4),
material VARCHAR(50),
grind_count INT NOT NULL DEFAULT 0,
total_rolled_weight DECIMAL(15,2) NOT NULL DEFAULT 0.00,
total_rolled_length DECIMAL(15,2) NOT NULL DEFAULT 0.00,
total_rolled_count INT NOT NULL DEFAULT 0,
manufacture_date DATE,
del_flag INT NOT NULL DEFAULT 0,
create_by VARCHAR(64), create_time DATETIME,
update_by VARCHAR(64), update_time DATETIME,
remark VARCHAR(500),
PRIMARY KEY (roll_id),
UNIQUE KEY uk_roll_no (roll_no)
) ENGINE=InnoDB COMMENT='轧辊库';
-- 换辊记录(四辊轧机,双机架)
CREATE TABLE mes_roll_change (
change_id BIGINT NOT NULL AUTO_INCREMENT,
change_no VARCHAR(50) COMMENT '换辊编号',
change_time DATETIME COMMENT '换辊时间',
stand_no VARCHAR(10) COMMENT '机架号: 1# / 2#',
change_type VARCHAR(20) COMMENT '换辊类型: 计划换辊/紧急换辊',
change_status VARCHAR(20),
operator VARCHAR(50),
-- 四支辊
upper_wr_no VARCHAR(50) COMMENT '上工作辊编号',
upper_wr_dia DECIMAL(10,2),
lower_wr_no VARCHAR(50) COMMENT '下工作辊编号',
lower_wr_dia DECIMAL(10,2),
upper_br_no VARCHAR(50) COMMENT '上支撑辊编号',
upper_br_dia DECIMAL(10,2),
lower_br_no VARCHAR(50) COMMENT '下支撑辊编号',
lower_br_dia DECIMAL(10,2),
del_flag INT NOT NULL DEFAULT 0,
create_by VARCHAR(64), create_time DATETIME,
update_by VARCHAR(64), update_time DATETIME,
remark VARCHAR(500),
PRIMARY KEY (change_id),
KEY idx_stand_time (stand_no, change_time)
) ENGINE=InnoDB COMMENT='换辊记录';
-- 下批轧辊(每条=一个辊位的备用辊)
CREATE TABLE mes_roll_standby (
standby_id BIGINT NOT NULL AUTO_INCREMENT,
stand_no VARCHAR(10) COMMENT '机架号: 1# / 2#',
roll_no VARCHAR(50) COMMENT '轧辊编号',
roll_type VARCHAR(10) COMMENT 'WR=工作辊 / BR=支撑辊',
position VARCHAR(10) COMMENT 'UP=上 / DOWN=下',
diameter DECIMAL(10,2),
roughness DECIMAL(10,4),
crown DECIMAL(10,4),
ready_time DATETIME,
del_flag INT NOT NULL DEFAULT 0,
create_by VARCHAR(64), create_time DATETIME,
update_by VARCHAR(64), update_time DATETIME,
remark VARCHAR(500),
PRIMARY KEY (standby_id)
) ENGINE=InnoDB COMMENT='下批轧辊(待换上)';