酸轧数据同步,轧辊新增产线新增各种产线
This commit is contained in:
@@ -38,21 +38,21 @@ public class MesRollChangeController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询指定机架当前在机轧辊(最近一次换辊记录)
|
||||
* GET /mes/rollChange/current?standNo=1%23
|
||||
* 查询指定产线+机架当前在机轧辊(最近一次换辊记录)
|
||||
* GET /mes/rollChange/current?lineId=xxx&standNo=1%23
|
||||
*/
|
||||
@GetMapping("/current")
|
||||
public R<MesRollChangeVo> current(@RequestParam String standNo) {
|
||||
return R.ok(iMesRollChangeService.queryCurrentByStand(standNo));
|
||||
public R<MesRollChangeVo> current(Long lineId, @RequestParam String standNo) {
|
||||
return R.ok(iMesRollChangeService.queryCurrentByStand(lineId, standNo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询各机架各辊位实时工作绩效(工作长度/卷数/重量)
|
||||
* GET /mes/rollChange/performance
|
||||
* 查询指定产线各机架各辊位实时工作绩效(工作长度/卷数/重量)
|
||||
* GET /mes/rollChange/performance?lineId=xxx
|
||||
*/
|
||||
@GetMapping("/performance")
|
||||
public R<Map<String, Map<String, Object>>> performance() {
|
||||
return R.ok(iMesRollChangeService.queryRollPerformance());
|
||||
public R<Map<String, Map<String, Object>>> performance(Long lineId) {
|
||||
return R.ok(iMesRollChangeService.queryRollPerformance(lineId));
|
||||
}
|
||||
|
||||
/** 详情 */
|
||||
|
||||
@@ -41,16 +41,16 @@ public class MesRollInfoController extends BaseController {
|
||||
return iMesRollInfoService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/** 状态统计卡片数据 */
|
||||
/** 状态统计卡片数据(lineId 为空时统计全部产线) */
|
||||
@GetMapping("/stats")
|
||||
public R<Map<String, Object>> stats() {
|
||||
return R.ok(iMesRollInfoService.queryStatusStats());
|
||||
public R<Map<String, Object>> stats(Long lineId) {
|
||||
return R.ok(iMesRollInfoService.queryStatusStats(lineId));
|
||||
}
|
||||
|
||||
/** 轧辊编号下拉列表(按辊型 + 状态过滤,均可为空) */
|
||||
/** 轧辊编号下拉列表(lineId / rollType / status 均可为空) */
|
||||
@GetMapping("/options")
|
||||
public R<List<String>> options(String rollType, String status) {
|
||||
return R.ok(iMesRollInfoService.queryRollNoList(rollType, status));
|
||||
public R<List<String>> options(Long lineId, String rollType, String status) {
|
||||
return R.ok(iMesRollInfoService.queryRollNoList(lineId, rollType, status));
|
||||
}
|
||||
|
||||
/** 详情 */
|
||||
@@ -90,13 +90,13 @@ public class MesRollInfoController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 从换辊记录同步在线状态
|
||||
* 从换辊记录同步在线状态(lineId 为空时同步全部产线)
|
||||
* 将当前各机架在机轧辊的状态强制修正为 Online,解决状态数据不一致问题
|
||||
*/
|
||||
@Log(title = "轧辊库-状态同步", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/syncStatus")
|
||||
public R<Void> syncStatus() {
|
||||
iMesRollInfoService.syncStatusFromChange();
|
||||
public R<Void> syncStatus(Long lineId) {
|
||||
iMesRollInfoService.syncStatusFromChange(lineId);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,12 +28,12 @@ public class MesRollStandbyController extends BaseController {
|
||||
private final IMesRollStandbyService iMesRollStandbyService;
|
||||
|
||||
/**
|
||||
* 查询指定机架的下批轧辊列表
|
||||
* GET /mes/rollStandby/list?standNo=1%23
|
||||
* 查询指定产线+机架的下批轧辊列表
|
||||
* GET /mes/rollStandby/list?lineId=xxx&standNo=1%23
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public R<List<MesRollStandbyVo>> list(@RequestParam String standNo) {
|
||||
return R.ok(iMesRollStandbyService.queryByStand(standNo));
|
||||
public R<List<MesRollStandbyVo>> list(Long lineId, @RequestParam String standNo) {
|
||||
return R.ok(iMesRollStandbyService.queryByStand(lineId, standNo));
|
||||
}
|
||||
|
||||
/** 详情 */
|
||||
@@ -66,12 +66,12 @@ public class MesRollStandbyController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空指定机架的全部下批轧辊
|
||||
* DELETE /mes/rollStandby/clear?standNo=1%23
|
||||
* 清空指定产线+机架的全部下批轧辊
|
||||
* DELETE /mes/rollStandby/clear?lineId=xxx&standNo=1%23
|
||||
*/
|
||||
@Log(title = "下批轧辊", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/clear")
|
||||
public R<Void> clear(@RequestParam String standNo) {
|
||||
return toAjax(iMesRollStandbyService.clearByStand(standNo));
|
||||
public R<Void> clear(Long lineId, @RequestParam String standNo) {
|
||||
return toAjax(iMesRollStandbyService.clearByStand(lineId, standNo));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,7 @@ import java.util.Date;
|
||||
|
||||
/**
|
||||
* 换辊记录 mes_roll_change
|
||||
* 四辊轧机,双机架(1# / 2#)
|
||||
* 每次换辊记录 4 支辊:上工作辊、下工作辊、上支撑辊、下支撑辊
|
||||
* 四辊轧机,支持多产线,每次换辊记录 4 支辊:上工作辊、下工作辊、上支撑辊、下支撑辊
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@@ -25,6 +24,9 @@ public class MesRollChange extends BaseEntity {
|
||||
@TableId(value = "change_id")
|
||||
private Long changeId;
|
||||
|
||||
/** 产线ID */
|
||||
private Long lineId;
|
||||
|
||||
/** 换辊编号 */
|
||||
private String changeNo;
|
||||
|
||||
|
||||
@@ -46,6 +46,9 @@ public class MesRollGrind extends BaseEntity {
|
||||
@TableId(value = "grind_id")
|
||||
private Long grindId;
|
||||
|
||||
/** 产线ID */
|
||||
private Long lineId;
|
||||
|
||||
/** 轧辊ID */
|
||||
private Long rollId;
|
||||
|
||||
|
||||
@@ -23,6 +23,9 @@ public class MesRollInfo extends BaseEntity {
|
||||
@TableId(value = "roll_id")
|
||||
private Long rollId;
|
||||
|
||||
/** 产线ID */
|
||||
private Long lineId;
|
||||
|
||||
/** 轧辊编号 */
|
||||
private String rollNo;
|
||||
|
||||
|
||||
@@ -30,6 +30,9 @@ public class MesRollStandby extends BaseEntity {
|
||||
@TableId(value = "standby_id")
|
||||
private Long standbyId;
|
||||
|
||||
/** 产线ID */
|
||||
private Long lineId;
|
||||
|
||||
/** 机架号:1# / 2# */
|
||||
private String standNo;
|
||||
|
||||
|
||||
@@ -18,6 +18,9 @@ public class MesRollChangeBo extends BaseEntity {
|
||||
|
||||
private Long changeId;
|
||||
|
||||
/** 产线ID(查询过滤 / 新增归属) */
|
||||
private Long lineId;
|
||||
|
||||
private String changeNo;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
|
||||
@@ -18,6 +18,9 @@ public class MesRollGrindBo extends BaseEntity {
|
||||
|
||||
private Long grindId;
|
||||
|
||||
/** 产线ID(查询过滤用) */
|
||||
private Long lineId;
|
||||
|
||||
@NotNull(message = "轧辊ID不能为空")
|
||||
private Long rollId;
|
||||
|
||||
|
||||
@@ -22,6 +22,9 @@ public class MesRollInfoBo extends BaseEntity {
|
||||
@NotNull(message = "轧辊ID不能为空", groups = EditGroup.class)
|
||||
private Long rollId;
|
||||
|
||||
/** 产线ID(查询过滤 / 新增归属) */
|
||||
private Long lineId;
|
||||
|
||||
@NotBlank(message = "轧辊编号不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String rollNo;
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@ public class MesRollStandbyBo extends BaseEntity {
|
||||
|
||||
private Long standbyId;
|
||||
|
||||
/** 产线ID(查询过滤 / 新增归属) */
|
||||
private Long lineId;
|
||||
|
||||
/** 机架号:1# / 2# */
|
||||
@NotBlank(message = "机架号不能为空", groups = AddGroup.class)
|
||||
private String standNo;
|
||||
|
||||
@@ -17,6 +17,8 @@ public class MesRollChangeVo {
|
||||
|
||||
private Long changeId;
|
||||
|
||||
private Long lineId;
|
||||
|
||||
private String changeNo;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
|
||||
@@ -19,6 +19,12 @@ public class MesRollInfoVo {
|
||||
@ExcelProperty("轧辊ID")
|
||||
private Long rollId;
|
||||
|
||||
@ExcelProperty("产线ID")
|
||||
private Long lineId;
|
||||
|
||||
@ExcelProperty("产线名称")
|
||||
private String lineName;
|
||||
|
||||
@ExcelProperty("轧辊编号")
|
||||
private String rollNo;
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ public class MesRollStandbyVo {
|
||||
|
||||
private Long standbyId;
|
||||
|
||||
private Long lineId;
|
||||
|
||||
/** 机架号:1# / 2# */
|
||||
private String standNo;
|
||||
|
||||
|
||||
@@ -13,27 +13,30 @@ import java.util.Map;
|
||||
*/
|
||||
public interface MesRollChangeMapper extends BaseMapperPlus<MesRollChangeMapper, MesRollChange, MesRollChangeVo> {
|
||||
|
||||
/** 查询指定机架最新一次换辊记录(当前在机轧辊) */
|
||||
MesRollChangeVo selectLatestByStand(@Param("standNo") String standNo);
|
||||
/** 查询指定产线+机架最新一次换辊记录(当前在机轧辊) */
|
||||
MesRollChangeVo selectLatestByStand(@Param("lineId") Long lineId, @Param("standNo") String standNo);
|
||||
|
||||
/**
|
||||
* 按辊位查询该位置最新一次有记录的换辊(支持部分换辊)
|
||||
* posType: upperWr / lowerWr / upperBr / lowerBr
|
||||
*/
|
||||
MesRollChangeVo selectLatestByStandAndPosition(@Param("standNo") String standNo,
|
||||
MesRollChangeVo selectLatestByStandAndPosition(@Param("lineId") Long lineId,
|
||||
@Param("standNo") String standNo,
|
||||
@Param("posType") String posType);
|
||||
|
||||
/**
|
||||
* 组合查询机架各辊位当前实际在机状态(每个位置独立取最新非空记录)
|
||||
* 组合查询指定产线+机架各辊位当前实际在机状态(每个位置独立取最新非空记录)
|
||||
* 返回 map,key 同 MesRollChangeVo 字段名(camelCase)
|
||||
*/
|
||||
Map<String, Object> selectCurrentStateByStand(@Param("standNo") String standNo);
|
||||
Map<String, Object> selectCurrentStateByStand(@Param("lineId") Long lineId, @Param("standNo") String standNo);
|
||||
|
||||
/**
|
||||
* 查询同机架下一次换辊时间(任意辊位有换辊即触发)
|
||||
* 查询同产线+机架下一次换辊时间(任意辊位有换辊即触发)
|
||||
* 返回 null 表示该辊仍在机
|
||||
*/
|
||||
Date selectNextChangeTime(@Param("standNo") String standNo, @Param("changeTime") Date changeTime);
|
||||
Date selectNextChangeTime(@Param("lineId") Long lineId,
|
||||
@Param("standNo") String standNo,
|
||||
@Param("changeTime") Date changeTime);
|
||||
|
||||
/**
|
||||
* 统计指定时间区间内的卷料生产统计:
|
||||
|
||||
@@ -15,13 +15,17 @@ public interface MesRollInfoMapper extends BaseMapperPlus<MesRollInfoMapper, Mes
|
||||
|
||||
/**
|
||||
* 按状态统计数量(用于总览卡片)
|
||||
* lineId 为 null 时统计全部产线
|
||||
*/
|
||||
List<Map<String, Object>> selectStatusStats();
|
||||
List<Map<String, Object>> selectStatusStats(@Param("lineId") Long lineId);
|
||||
|
||||
/**
|
||||
* 查询轧辊编号列表(用于下拉选择,可按辊型和状态过滤)
|
||||
* 查询轧辊编号列表(用于下拉选择,可按产线、辊型、状态过滤)
|
||||
* lineId 为 null 时不过滤产线
|
||||
*/
|
||||
List<String> selectRollNoList(@Param("rollType") String rollType, @Param("status") String status);
|
||||
List<String> selectRollNoList(@Param("lineId") Long lineId,
|
||||
@Param("rollType") String rollType,
|
||||
@Param("status") String status);
|
||||
|
||||
/**
|
||||
* 按轧辊编号查询(用于换辊时同步状态)
|
||||
|
||||
@@ -12,9 +12,9 @@ import java.util.List;
|
||||
*/
|
||||
public interface MesRollStandbyMapper extends BaseMapperPlus<MesRollStandbyMapper, MesRollStandby, MesRollStandbyVo> {
|
||||
|
||||
/** 按机架查询下批轧辊列表 */
|
||||
List<MesRollStandbyVo> selectByStand(@Param("standNo") String standNo);
|
||||
/** 按产线+机架查询下批轧辊列表 */
|
||||
List<MesRollStandbyVo> selectByStand(@Param("lineId") Long lineId, @Param("standNo") String standNo);
|
||||
|
||||
/** 清空某机架的下批轧辊 */
|
||||
int clearByStand(@Param("standNo") String standNo);
|
||||
/** 清空指定产线+机架的下批轧辊 */
|
||||
int clearByStand(@Param("lineId") Long lineId, @Param("standNo") String standNo);
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ public interface IMesRollChangeService {
|
||||
|
||||
MesRollChangeVo queryById(Long changeId);
|
||||
|
||||
/** 查询指定机架当前在机轧辊(最新一次换辊记录) */
|
||||
MesRollChangeVo queryCurrentByStand(String standNo);
|
||||
/** 查询指定产线+机架当前在机轧辊(最新一次换辊记录) */
|
||||
MesRollChangeVo queryCurrentByStand(Long lineId, String standNo);
|
||||
|
||||
TableDataInfo<MesRollChangeVo> queryPageList(MesRollChangeBo bo, PageQuery pageQuery);
|
||||
|
||||
@@ -28,9 +28,9 @@ public interface IMesRollChangeService {
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
/**
|
||||
* 查询各机架各辊位的实时工作绩效(工作长度/卷数/重量)
|
||||
* 查询指定产线各机架各辊位的实时工作绩效(工作长度/卷数/重量)
|
||||
* 返回结构: { posType -> { standNo -> { rollNo, workLength, coilCount, totalWeight } } }
|
||||
* posType: upperBr / upperWr / lowerWr / lowerBr
|
||||
*/
|
||||
Map<String, Map<String, Object>> queryRollPerformance();
|
||||
Map<String, Map<String, Object>> queryRollPerformance(Long lineId);
|
||||
}
|
||||
|
||||
@@ -20,11 +20,16 @@ public interface IMesRollInfoService {
|
||||
|
||||
List<MesRollInfoVo> queryList(MesRollInfoBo bo);
|
||||
|
||||
/** 按状态统计(总览卡片) */
|
||||
Map<String, Object> queryStatusStats();
|
||||
/**
|
||||
* 按状态统计(总览卡片)
|
||||
* lineId 为 null 时统计全部产线
|
||||
*/
|
||||
Map<String, Object> queryStatusStats(Long lineId);
|
||||
|
||||
/** 轧辊编号下拉列表(status 为 null 时不过滤状态) */
|
||||
List<String> queryRollNoList(String rollType, String status);
|
||||
/**
|
||||
* 轧辊编号下拉列表(lineId / rollType / status 均可为 null,不过滤对应维度)
|
||||
*/
|
||||
List<String> queryRollNoList(Long lineId, String rollType, String status);
|
||||
|
||||
Long insertByBo(MesRollInfoBo bo);
|
||||
|
||||
@@ -40,6 +45,7 @@ public interface IMesRollInfoService {
|
||||
* 每个机架最新一次换辊记录中的 4 支辊 → Online;
|
||||
* 下批辊列表中的辊 → Standby(已由 addStandby 维护,此处不重复处理);
|
||||
* 其余不变,仅修正当前在机辊的状态数据不一致问题。
|
||||
* lineId 为 null 时同步全部产线;指定 lineId 时仅同步该产线。
|
||||
*/
|
||||
void syncStatusFromChange();
|
||||
void syncStatusFromChange(Long lineId);
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ public interface IMesRollStandbyService {
|
||||
|
||||
MesRollStandbyVo queryById(Long standbyId);
|
||||
|
||||
/** 查询指定机架的下批轧辊列表 */
|
||||
List<MesRollStandbyVo> queryByStand(String standNo);
|
||||
/** 查询指定产线+机架的下批轧辊列表 */
|
||||
List<MesRollStandbyVo> queryByStand(Long lineId, String standNo);
|
||||
|
||||
/** 新增下批轧辊,同步将该辊状态更新为 Standby */
|
||||
Long addStandby(MesRollStandbyBo bo);
|
||||
@@ -24,6 +24,6 @@ public interface IMesRollStandbyService {
|
||||
/** 删除某条下批轧辊,同步将该辊状态恢复为 Offline */
|
||||
Boolean deleteById(Long standbyId);
|
||||
|
||||
/** 清空指定机架的全部下批轧辊,并将对应辊状态恢复为 Offline */
|
||||
Boolean clearByStand(String standNo);
|
||||
/** 清空指定产线+机架的全部下批轧辊,并将对应辊状态恢复为 Offline */
|
||||
Boolean clearByStand(Long lineId, String standNo);
|
||||
}
|
||||
|
||||
@@ -44,11 +44,12 @@ public class MesRollChangeServiceImpl implements IMesRollChangeService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public MesRollChangeVo queryCurrentByStand(String standNo) {
|
||||
public MesRollChangeVo queryCurrentByStand(Long lineId, String standNo) {
|
||||
// 组合各辊位最新状态,转换为 VO
|
||||
Map<String, Object> state = baseMapper.selectCurrentStateByStand(standNo);
|
||||
Map<String, Object> state = baseMapper.selectCurrentStateByStand(lineId, standNo);
|
||||
if (state == null) return null;
|
||||
MesRollChangeVo vo = new MesRollChangeVo();
|
||||
vo.setLineId(lineId);
|
||||
vo.setStandNo(standNo);
|
||||
vo.setUpperWrNo(str(state.get("upperWrNo")));
|
||||
vo.setUpperWrDia(decimal(state.get("upperWrDia")));
|
||||
@@ -70,7 +71,7 @@ public class MesRollChangeServiceImpl implements IMesRollChangeService {
|
||||
Page<MesRollChangeVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
// 为每条换辊记录计算:工作长度、卷数、重量
|
||||
for (MesRollChangeVo vo : result.getRecords()) {
|
||||
Date endTime = baseMapper.selectNextChangeTime(vo.getStandNo(), vo.getChangeTime());
|
||||
Date endTime = baseMapper.selectNextChangeTime(vo.getLineId(), vo.getStandNo(), vo.getChangeTime());
|
||||
Map<String, Object> stats = baseMapper.selectCoilStats(vo.getChangeTime(), endTime);
|
||||
fillStatsToVo(vo, stats);
|
||||
}
|
||||
@@ -81,12 +82,12 @@ public class MesRollChangeServiceImpl implements IMesRollChangeService {
|
||||
private static final List<String> STANDS = Arrays.asList("1#", "2#");
|
||||
|
||||
@Override
|
||||
public Map<String, Map<String, Object>> queryRollPerformance() {
|
||||
public Map<String, Map<String, Object>> queryRollPerformance(Long lineId) {
|
||||
Map<String, Map<String, Object>> result = new HashMap<>(4);
|
||||
for (String posType : POS_TYPES) {
|
||||
Map<String, Object> byStand = new HashMap<>(2);
|
||||
for (String standNo : STANDS) {
|
||||
MesRollChangeVo rec = baseMapper.selectLatestByStandAndPosition(standNo, posType);
|
||||
MesRollChangeVo rec = baseMapper.selectLatestByStandAndPosition(lineId, standNo, posType);
|
||||
Map<String, Object> cell = new HashMap<>(6);
|
||||
if (rec != null) {
|
||||
cell.put("rollNo", getRollNoByPos(rec, posType));
|
||||
@@ -106,9 +107,9 @@ public class MesRollChangeServiceImpl implements IMesRollChangeService {
|
||||
}
|
||||
|
||||
/** 若该辊位要换新辊,则把当前在机的旧辊下线 */
|
||||
private void offlineIfReplaced(String standNo, String posType, String newRollNo) {
|
||||
private void offlineIfReplaced(Long lineId, String standNo, String posType, String newRollNo) {
|
||||
if (StringUtils.isBlank(newRollNo)) return;
|
||||
MesRollChangeVo cur = baseMapper.selectLatestByStandAndPosition(standNo, posType);
|
||||
MesRollChangeVo cur = baseMapper.selectLatestByStandAndPosition(lineId, standNo, posType);
|
||||
if (cur != null) {
|
||||
String oldRollNo = getRollNoByPos(cur, posType);
|
||||
if (StringUtils.isNotBlank(oldRollNo)) {
|
||||
@@ -158,6 +159,7 @@ public class MesRollChangeServiceImpl implements IMesRollChangeService {
|
||||
|
||||
private LambdaQueryWrapper<MesRollChange> buildQueryWrapper(MesRollChangeBo bo) {
|
||||
LambdaQueryWrapper<MesRollChange> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(bo.getLineId() != null, MesRollChange::getLineId, bo.getLineId());
|
||||
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());
|
||||
@@ -184,10 +186,10 @@ public class MesRollChangeServiceImpl implements IMesRollChangeService {
|
||||
add.setChangeType("三级换辊");
|
||||
}
|
||||
// 按辊位独立换辊:只下线被替换的那个位置的旧辊
|
||||
offlineIfReplaced(add.getStandNo(), "upperWr", add.getUpperWrNo());
|
||||
offlineIfReplaced(add.getStandNo(), "lowerWr", add.getLowerWrNo());
|
||||
offlineIfReplaced(add.getStandNo(), "upperBr", add.getUpperBrNo());
|
||||
offlineIfReplaced(add.getStandNo(), "lowerBr", add.getLowerBrNo());
|
||||
offlineIfReplaced(add.getLineId(), add.getStandNo(), "upperWr", add.getUpperWrNo());
|
||||
offlineIfReplaced(add.getLineId(), add.getStandNo(), "lowerWr", add.getLowerWrNo());
|
||||
offlineIfReplaced(add.getLineId(), add.getStandNo(), "upperBr", add.getUpperBrNo());
|
||||
offlineIfReplaced(add.getLineId(), add.getStandNo(), "lowerBr", add.getLowerBrNo());
|
||||
|
||||
baseMapper.insert(add);
|
||||
|
||||
|
||||
@@ -52,8 +52,8 @@ public class MesRollInfoServiceImpl implements IMesRollInfoService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryStatusStats() {
|
||||
List<Map<String, Object>> rows = baseMapper.selectStatusStats();
|
||||
public Map<String, Object> queryStatusStats(Long lineId) {
|
||||
List<Map<String, Object>> rows = baseMapper.selectStatusStats(lineId);
|
||||
Map<String, Object> result = new HashMap<String, Object>(8);
|
||||
int total = 0;
|
||||
for (Map<String, Object> row : rows) {
|
||||
@@ -67,12 +67,13 @@ public class MesRollInfoServiceImpl implements IMesRollInfoService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> queryRollNoList(String rollType, String status) {
|
||||
return baseMapper.selectRollNoList(rollType, status);
|
||||
public List<String> queryRollNoList(Long lineId, String rollType, String status) {
|
||||
return baseMapper.selectRollNoList(lineId, rollType, status);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<MesRollInfo> buildQueryWrapper(MesRollInfoBo bo) {
|
||||
LambdaQueryWrapper<MesRollInfo> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(bo.getLineId() != null, MesRollInfo::getLineId, bo.getLineId());
|
||||
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());
|
||||
@@ -120,11 +121,11 @@ public class MesRollInfoServiceImpl implements IMesRollInfoService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncStatusFromChange() {
|
||||
public void syncStatusFromChange(Long lineId) {
|
||||
// 按辊位独立取最新在机辊,确保各位置状态正确
|
||||
for (String standNo : Arrays.asList("1#", "2#")) {
|
||||
for (String posType : Arrays.asList("upperWr", "lowerWr", "upperBr", "lowerBr")) {
|
||||
MesRollChangeVo rec = rollChangeMapper.selectLatestByStandAndPosition(standNo, posType);
|
||||
MesRollChangeVo rec = rollChangeMapper.selectLatestByStandAndPosition(lineId, standNo, posType);
|
||||
if (rec == null) continue;
|
||||
String rollNo = getRollNoByPos(rec, posType);
|
||||
if (StringUtils.isNotBlank(rollNo)) {
|
||||
|
||||
@@ -31,8 +31,8 @@ public class MesRollStandbyServiceImpl implements IMesRollStandbyService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MesRollStandbyVo> queryByStand(String standNo) {
|
||||
return baseMapper.selectByStand(standNo);
|
||||
public List<MesRollStandbyVo> queryByStand(Long lineId, String standNo) {
|
||||
return baseMapper.selectByStand(lineId, standNo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,10 +70,10 @@ public class MesRollStandbyServiceImpl implements IMesRollStandbyService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean clearByStand(String standNo) {
|
||||
public Boolean clearByStand(Long lineId, String standNo) {
|
||||
// 先查出所有辊号再清空
|
||||
List<MesRollStandbyVo> list = baseMapper.selectByStand(standNo);
|
||||
int rows = baseMapper.clearByStand(standNo);
|
||||
List<MesRollStandbyVo> list = baseMapper.selectByStand(lineId, standNo);
|
||||
int rows = baseMapper.clearByStand(lineId, standNo);
|
||||
for (MesRollStandbyVo vo : list) {
|
||||
if (StringUtils.isNotBlank(vo.getRollNo())) {
|
||||
// 只有仍处于 Standby 状态时才回退为 Offline(换辊后已变 Online 的不动)
|
||||
|
||||
@@ -2,26 +2,28 @@
|
||||
<!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,
|
||||
SELECT change_id, line_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}
|
||||
<if test="lineId != null">AND line_id = #{lineId}</if>
|
||||
ORDER BY change_time DESC, change_id DESC
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 按辊位查最新非空换辊记录(支持部分换辊) -->
|
||||
<select id="selectLatestByStandAndPosition" resultType="com.klp.mes.roll.domain.vo.MesRollChangeVo">
|
||||
SELECT change_id, change_no, change_time, stand_no, operator,
|
||||
SELECT change_id, line_id, change_no, change_time, stand_no, 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
|
||||
FROM mes_roll_change
|
||||
WHERE del_flag = 0 AND stand_no = #{standNo}
|
||||
<if test="lineId != null">AND line_id = #{lineId}</if>
|
||||
<choose>
|
||||
<when test="posType == 'upperWr'">AND upper_wr_no IS NOT NULL AND upper_wr_no != ''</when>
|
||||
<when test="posType == 'lowerWr'">AND lower_wr_no IS NOT NULL AND lower_wr_no != ''</when>
|
||||
@@ -35,24 +37,25 @@
|
||||
<!-- 组合查询各辊位当前实际在机状态(每个位置独立取最新非空记录) -->
|
||||
<select id="selectCurrentStateByStand" resultType="map">
|
||||
SELECT
|
||||
(SELECT upper_wr_no FROM mes_roll_change WHERE stand_no = #{standNo} AND del_flag = 0 AND upper_wr_no IS NOT NULL AND upper_wr_no != '' ORDER BY change_time DESC, change_id DESC LIMIT 1) AS upperWrNo,
|
||||
(SELECT upper_wr_dia FROM mes_roll_change WHERE stand_no = #{standNo} AND del_flag = 0 AND upper_wr_no IS NOT NULL AND upper_wr_no != '' ORDER BY change_time DESC, change_id DESC LIMIT 1) AS upperWrDia,
|
||||
(SELECT lower_wr_no FROM mes_roll_change WHERE stand_no = #{standNo} AND del_flag = 0 AND lower_wr_no IS NOT NULL AND lower_wr_no != '' ORDER BY change_time DESC, change_id DESC LIMIT 1) AS lowerWrNo,
|
||||
(SELECT lower_wr_dia FROM mes_roll_change WHERE stand_no = #{standNo} AND del_flag = 0 AND lower_wr_no IS NOT NULL AND lower_wr_no != '' ORDER BY change_time DESC, change_id DESC LIMIT 1) AS lowerWrDia,
|
||||
(SELECT upper_br_no FROM mes_roll_change WHERE stand_no = #{standNo} AND del_flag = 0 AND upper_br_no IS NOT NULL AND upper_br_no != '' ORDER BY change_time DESC, change_id DESC LIMIT 1) AS upperBrNo,
|
||||
(SELECT upper_br_dia FROM mes_roll_change WHERE stand_no = #{standNo} AND del_flag = 0 AND upper_br_no IS NOT NULL AND upper_br_no != '' ORDER BY change_time DESC, change_id DESC LIMIT 1) AS upperBrDia,
|
||||
(SELECT lower_br_no FROM mes_roll_change WHERE stand_no = #{standNo} AND del_flag = 0 AND lower_br_no IS NOT NULL AND lower_br_no != '' ORDER BY change_time DESC, change_id DESC LIMIT 1) AS lowerBrNo,
|
||||
(SELECT lower_br_dia FROM mes_roll_change WHERE stand_no = #{standNo} AND del_flag = 0 AND lower_br_no IS NOT NULL AND lower_br_no != '' ORDER BY change_time DESC, change_id DESC LIMIT 1) AS lowerBrDia,
|
||||
(SELECT MAX(change_time) FROM mes_roll_change WHERE stand_no = #{standNo} AND del_flag = 0) AS changeTime
|
||||
(SELECT upper_wr_no FROM mes_roll_change WHERE stand_no = #{standNo} AND del_flag = 0 <if test="lineId != null">AND line_id = #{lineId}</if> AND upper_wr_no IS NOT NULL AND upper_wr_no != '' ORDER BY change_time DESC, change_id DESC LIMIT 1) AS upperWrNo,
|
||||
(SELECT upper_wr_dia FROM mes_roll_change WHERE stand_no = #{standNo} AND del_flag = 0 <if test="lineId != null">AND line_id = #{lineId}</if> AND upper_wr_no IS NOT NULL AND upper_wr_no != '' ORDER BY change_time DESC, change_id DESC LIMIT 1) AS upperWrDia,
|
||||
(SELECT lower_wr_no FROM mes_roll_change WHERE stand_no = #{standNo} AND del_flag = 0 <if test="lineId != null">AND line_id = #{lineId}</if> AND lower_wr_no IS NOT NULL AND lower_wr_no != '' ORDER BY change_time DESC, change_id DESC LIMIT 1) AS lowerWrNo,
|
||||
(SELECT lower_wr_dia FROM mes_roll_change WHERE stand_no = #{standNo} AND del_flag = 0 <if test="lineId != null">AND line_id = #{lineId}</if> AND lower_wr_no IS NOT NULL AND lower_wr_no != '' ORDER BY change_time DESC, change_id DESC LIMIT 1) AS lowerWrDia,
|
||||
(SELECT upper_br_no FROM mes_roll_change WHERE stand_no = #{standNo} AND del_flag = 0 <if test="lineId != null">AND line_id = #{lineId}</if> AND upper_br_no IS NOT NULL AND upper_br_no != '' ORDER BY change_time DESC, change_id DESC LIMIT 1) AS upperBrNo,
|
||||
(SELECT upper_br_dia FROM mes_roll_change WHERE stand_no = #{standNo} AND del_flag = 0 <if test="lineId != null">AND line_id = #{lineId}</if> AND upper_br_no IS NOT NULL AND upper_br_no != '' ORDER BY change_time DESC, change_id DESC LIMIT 1) AS upperBrDia,
|
||||
(SELECT lower_br_no FROM mes_roll_change WHERE stand_no = #{standNo} AND del_flag = 0 <if test="lineId != null">AND line_id = #{lineId}</if> AND lower_br_no IS NOT NULL AND lower_br_no != '' ORDER BY change_time DESC, change_id DESC LIMIT 1) AS lowerBrNo,
|
||||
(SELECT lower_br_dia FROM mes_roll_change WHERE stand_no = #{standNo} AND del_flag = 0 <if test="lineId != null">AND line_id = #{lineId}</if> AND lower_br_no IS NOT NULL AND lower_br_no != '' ORDER BY change_time DESC, change_id DESC LIMIT 1) AS lowerBrDia,
|
||||
(SELECT MAX(change_time) FROM mes_roll_change WHERE stand_no = #{standNo} AND del_flag = 0 <if test="lineId != null">AND line_id = #{lineId}</if>) AS changeTime
|
||||
</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}
|
||||
<if test="lineId != null">AND line_id = #{lineId}</if>
|
||||
</select>
|
||||
|
||||
<!--
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
SELECT status, COUNT(*) AS cnt
|
||||
FROM mes_roll_info
|
||||
WHERE del_flag = 0
|
||||
<if test="lineId != null">AND line_id = #{lineId}</if>
|
||||
GROUP BY status
|
||||
</select>
|
||||
|
||||
@@ -15,6 +16,7 @@
|
||||
SELECT roll_no FROM mes_roll_info
|
||||
WHERE del_flag = 0
|
||||
AND status != 'Scrapped'
|
||||
<if test="lineId != null">AND line_id = #{lineId}</if>
|
||||
<if test="rollType != null and rollType != ''">
|
||||
AND roll_type = #{rollType}
|
||||
</if>
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
<!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,
|
||||
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 '上工作辊'
|
||||
@@ -17,17 +17,19 @@
|
||||
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>
|
||||
|
||||
<!-- 逻辑删除指定机架所有下批轧辊(清空) -->
|
||||
<!-- 逻辑删除指定产线+机架所有下批轧辊(清空) -->
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user