package com.shlb.timescaledbutils.constant;
|
|
import java.util.*;
|
|
/**
|
* 系统常量类
|
*/
|
public class AppConstants {
|
private AppConstants() {
|
// 防止实例化
|
}
|
|
/**
|
* 班次 1、2、3
|
* 卷接机组 101~200
|
* 包装机组 201~300
|
* 装封箱机组 301~400
|
* 成型机组 401~500
|
* 发射机组 501~600
|
* 提升机 601
|
* 喂丝机 603
|
*/
|
|
|
// 所有设备编号 (不含班次前缀)
|
public static final List<String> EQUIPMENT_LIST = Arrays.asList(
|
// 卷接机组
|
"101", "102", "103", "105", "106", "107", "108", "109", "110", "111", "113",
|
// 包装机组
|
"201", "202", "203", "205", "206", "207", "208", "209", "210", "211", "213",
|
// 装封箱机组
|
"301", "302", "303", "304", "305",
|
// 成型机组
|
"401", "402", "403",
|
// 发射机组
|
"501", "502", "503",
|
// 提升机
|
"601",
|
// 喂丝机
|
"603"
|
);
|
|
|
// 设备类型常量
|
public static final int TYPE_ROLLING = 1; // 卷接机组
|
public static final int TYPE_PACKAGING = 2; // 包装机组
|
public static final int TYPE_SEALING = 3; // 装封箱机组
|
public static final int TYPE_FORMING = 4; // 成型机组
|
public static final int TYPE_LAUNCHING = 5; // 发射机组
|
public static final int TYPE_LIFTING = 6; // 提升机
|
public static final int TYPE_FEED = 7; // 喂丝机
|
|
// 班次常量
|
public static final int SHIFT_MORNING = 1; // 早班
|
public static final int SHIFT_MIDDLE = 2; // 中班
|
public static final int SHIFT_NIGHT = 3; // 晚班
|
|
/**
|
* 获取设备类型
|
* @param equipmentCode 设备编号,可以是3位(如"101")或4位(如"1101")
|
* @return 1-卷接机组, 2-包装机组, 3-装封箱机组, 4-成型机组, 5-发射机组, 6-提升机, 7-喂丝机, 0-无效
|
*/
|
public static int getEquipmentType(String equipmentCode) {
|
if (equipmentCode == null || equipmentCode.length() < 3) {
|
return 0;
|
}
|
|
// 特殊设备判断:603为喂丝机(TYPE=7),601为提升机(TYPE=6)
|
// 无论是 "603" 还是 "1603",endsWith 都能正确判断
|
if (equipmentCode.endsWith("603")) {
|
return TYPE_FEED;
|
}
|
if (equipmentCode.endsWith("601")) {
|
return TYPE_LIFTING;
|
}
|
|
// 获取类型位的索引
|
// 如果是4位编码(如1101),类型位在索引1
|
// 如果是3位编码(如101),类型位在索引0
|
int typeIndex = equipmentCode.length() == 4 ? 1 : 0;
|
|
if (typeIndex >= equipmentCode.length()) {
|
return 0;
|
}
|
|
char typeChar = equipmentCode.charAt(typeIndex);
|
int type = Character.getNumericValue(typeChar);
|
|
return (type >= 1 && type <= 7) ? type : 0;
|
}
|
|
}
|