|
|
@@ -96,55 +96,83 @@ public class MesProductCncParamController extends BaseController {
|
|
|
return "modules/mes/mesProductCncParamDetail";
|
|
|
}
|
|
|
|
|
|
- /** CNC参数代码与中文名称映射(展示用主代码 = 实际字段名) */
|
|
|
+ /** CNC参数主代码与中文名称映射(按展示顺序,仅展示这8项) */
|
|
|
private static final Map<String, String> CNC_PARAM_LABELS = new LinkedHashMap<>();
|
|
|
- /** 同一参数的别名(旧字段名 → 主代码),用于取值兼容 */
|
|
|
+ /** 主代码 → 参数地址(展示用) */
|
|
|
+ private static final Map<String, String> CNC_PARAM_ADDRESSES = new LinkedHashMap<>();
|
|
|
+ /** 同一参数的别名(路径/旧短名 → 主代码),用于取值兼容 */
|
|
|
private static final Map<String, String> CNC_PARAM_ALIASES = new LinkedHashMap<>();
|
|
|
+ /** 固定显示值的参数 */
|
|
|
+ private static final Map<String, String> CNC_PARAM_FIXED_VALUES = new LinkedHashMap<>();
|
|
|
+ /** 需要按 ON/OFF 展示的布尔类参数 */
|
|
|
+ private static final java.util.Set<String> CNC_PARAM_ON_OFF = new java.util.HashSet<>();
|
|
|
static {
|
|
|
- CNC_PARAM_LABELS.put("spindleActSpeed", "主轴转速");
|
|
|
- CNC_PARAM_LABELS.put("machineX", "X轴机械坐标");
|
|
|
- CNC_PARAM_LABELS.put("machineY", "Y轴机械坐标");
|
|
|
- CNC_PARAM_LABELS.put("machineZ", "Z轴机械坐标");
|
|
|
- CNC_PARAM_LABELS.put("actPressure", "实际压力值");
|
|
|
- CNC_PARAM_LABELS.put("aaOffValZ", "Z轴叠加总量");
|
|
|
- CNC_PARAM_LABELS.put("cutActSpeedX", "X轴进给率实际值");
|
|
|
- CNC_PARAM_LABELS.put("cutActSpeedY", "Y轴进给率实际值");
|
|
|
- CNC_PARAM_LABELS.put("cutActSpeedZ", "Z轴进给率实际值");
|
|
|
- CNC_PARAM_LABELS.put("r210", "参数R210-恒压力开启延时");
|
|
|
- CNC_PARAM_LABELS.put("r211", "参数R211-设定压力值");
|
|
|
- CNC_PARAM_LABELS.put("r212", "参数R212-调整下限值");
|
|
|
- CNC_PARAM_LABELS.put("r213", "参数R213-调整速度");
|
|
|
- CNC_PARAM_LABELS.put("r214", "参数R214-叠加极限值");
|
|
|
- CNC_PARAM_LABELS.put("r215", "参数R215-压力波动值");
|
|
|
- CNC_PARAM_LABELS.put("r216", "参数R216-采集取样次数");
|
|
|
- CNC_PARAM_LABELS.put("r217", "参数R217-手动调整值");
|
|
|
- CNC_PARAM_LABELS.put("r218", "参数R218-暂停再启动延时");
|
|
|
- CNC_PARAM_LABELS.put("r999", "参数R999-投影半径");
|
|
|
-
|
|
|
- // 旧字段名兼容
|
|
|
- CNC_PARAM_ALIASES.put("SP_SPEED", "spindleActSpeed");
|
|
|
- CNC_PARAM_ALIASES.put("X_MCS", "machineX");
|
|
|
- CNC_PARAM_ALIASES.put("Y_MCS", "machineY");
|
|
|
- CNC_PARAM_ALIASES.put("Z_MCS", "machineZ");
|
|
|
- CNC_PARAM_ALIASES.put("Actual_Pressure", "actPressure");
|
|
|
- CNC_PARAM_ALIASES.put("AA_OFF_VAL_Z", "aaOffValZ");
|
|
|
- CNC_PARAM_ALIASES.put("X_Feed", "cutActSpeedX");
|
|
|
- CNC_PARAM_ALIASES.put("Y_Feed", "cutActSpeedY");
|
|
|
- CNC_PARAM_ALIASES.put("Z_Feed", "cutActSpeedZ");
|
|
|
- CNC_PARAM_ALIASES.put("R210", "r210");
|
|
|
- CNC_PARAM_ALIASES.put("R211", "r211");
|
|
|
- CNC_PARAM_ALIASES.put("R212", "r212");
|
|
|
- CNC_PARAM_ALIASES.put("R213", "r213");
|
|
|
- CNC_PARAM_ALIASES.put("R214", "r214");
|
|
|
- CNC_PARAM_ALIASES.put("R215", "r215");
|
|
|
- CNC_PARAM_ALIASES.put("R216", "r216");
|
|
|
- CNC_PARAM_ALIASES.put("R217", "r217");
|
|
|
- CNC_PARAM_ALIASES.put("R218", "r218");
|
|
|
- CNC_PARAM_ALIASES.put("R999", "r999");
|
|
|
+ CNC_PARAM_LABELS.put("cmdFeedRateIpo", "设定进给速度");
|
|
|
+ CNC_PARAM_LABELS.put("cmdSpindleSpeed", "设定主轴转速");
|
|
|
+ CNC_PARAM_LABELS.put("hydraulicPressure", "液压压力");
|
|
|
+ CNC_PARAM_LABELS.put("airPressure", "气压压力");
|
|
|
+ CNC_PARAM_LABELS.put("panelFeedRateOvr", "面板进给倍率");
|
|
|
+ CNC_PARAM_LABELS.put("panelSpindleOvr", "面板主轴倍率");
|
|
|
+ CNC_PARAM_LABELS.put("spindleActSpeed", "实际主轴转速");
|
|
|
+ CNC_PARAM_LABELS.put("actFeedRateIpo", "实际进给速度");
|
|
|
+
|
|
|
+ CNC_PARAM_ADDRESSES.put("cmdFeedRateIpo", "cmdFeedRateIpo");
|
|
|
+ CNC_PARAM_ADDRESSES.put("cmdSpindleSpeed", "cmdSpindleSpeed");
|
|
|
+ CNC_PARAM_ADDRESSES.put("hydraulicPressure", "hydraulicPressure");
|
|
|
+ CNC_PARAM_ADDRESSES.put("airPressure", "airPressure");
|
|
|
+ CNC_PARAM_ADDRESSES.put("panelFeedRateOvr", "panelFeedRateOvr");
|
|
|
+ CNC_PARAM_ADDRESSES.put("panelSpindleOvr", "panelSpindleOvr");
|
|
|
+ CNC_PARAM_ADDRESSES.put("spindleActSpeed", "spindleActSpeed");
|
|
|
+ CNC_PARAM_ADDRESSES.put("actFeedRateIpo", "actFeedRateIpo");
|
|
|
+
|
|
|
+ CNC_PARAM_ON_OFF.add("hydraulicPressure");
|
|
|
+ CNC_PARAM_ON_OFF.add("airPressure");
|
|
|
+
|
|
|
+ // 短名 / 旧字段名 / 路径 / OPC NodeId 兼容
|
|
|
+ addAliases("cmdFeedRateIpo",
|
|
|
+ "/Channel/State/cmdFeedRateIpo",
|
|
|
+ "Channel/State/cmdFeedRateIpo", "ns=2;s=/Channel/State/cmdFeedRateIpo");
|
|
|
+ addAliases("cmdSpindleSpeed",
|
|
|
+ "cmdSpeed",
|
|
|
+ "/Channel/Spindle/cmdSpeed", "/Channel/Spindle/cmdSpindleSpeed",
|
|
|
+ "Channel/Spindle/cmdSpeed", "Channel/Spindle/cmdSpindleSpeed",
|
|
|
+ "ns=2;s=/Channel/Spindle/cmdSpeed", "ns=2;s=/Channel/Spindle/cmdSpindleSpeed");
|
|
|
+ addAliases("hydraulicPressure",
|
|
|
+ "/Plc/I6.2", "Plc/I6.2", "I6.2",
|
|
|
+ "ns=2;s=/Plc/I6.2");
|
|
|
+ addAliases("airPressure",
|
|
|
+ "/Plc/I3.5", "Plc/I3.5", "I3.5",
|
|
|
+ "ns=2;s=/Plc/I3.5");
|
|
|
+ addAliases("panelFeedRateOvr",
|
|
|
+ "feedRateOvr",
|
|
|
+ "/Channel/MachineAxis/feedRateOvr", "/Channel/MachineAxis/panelFeedRateOvr",
|
|
|
+ "Channel/MachineAxis/feedRateOvr", "Channel/MachineAxis/panelFeedRateOvr",
|
|
|
+ "ns=2;s=/Channel/MachineAxis/feedRateOvr", "ns=2;s=/Channel/MachineAxis/panelFeedRateOvr");
|
|
|
+ addAliases("panelSpindleOvr",
|
|
|
+ "speedOvr",
|
|
|
+ "/Channel/Spindle/speedOvr", "/Channel/Spindle/panelSpindleOvr",
|
|
|
+ "Channel/Spindle/speedOvr", "Channel/Spindle/panelSpindleOvr",
|
|
|
+ "ns=2;s=/Channel/Spindle/speedOvr", "ns=2;s=/Channel/Spindle/panelSpindleOvr");
|
|
|
+ addAliases("spindleActSpeed",
|
|
|
+ "actSpeed", "SP_SPEED",
|
|
|
+ "/Channel/Spindle/actSpeed", "/Channel/Spindle/spindleActSpeed",
|
|
|
+ "Channel/Spindle/actSpeed", "Channel/Spindle/spindleActSpeed",
|
|
|
+ "ns=2;s=/Channel/Spindle/actSpeed", "ns=2;s=/Channel/Spindle/spindleActSpeed");
|
|
|
+ addAliases("actFeedRateIpo",
|
|
|
+ "/Channel/State/actFeedRateIpo",
|
|
|
+ "Channel/State/actFeedRateIpo", "ns=2;s=/Channel/State/actFeedRateIpo");
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void addAliases(String primaryKey, String... aliases) {
|
|
|
+ for (String alias : aliases) {
|
|
|
+ if (StringUtils.isNotBlank(alias)) {
|
|
|
+ CNC_PARAM_ALIASES.put(alias, primaryKey);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 单条记录时,构建参数代码/名称/值列表(含未映射字段)
|
|
|
+ * 单条记录时,构建参数地址/名称/值列表(仅展示已映射的8项)
|
|
|
*/
|
|
|
private List<Map<String, Object>> buildParamItems(List<JSONObject> paramRows) {
|
|
|
List<Map<String, Object>> items = new ArrayList<>();
|
|
|
@@ -153,32 +181,27 @@ public class MesProductCncParamController extends BaseController {
|
|
|
}
|
|
|
JSONObject row = paramRows.get(0);
|
|
|
for (Map.Entry<String, String> labelEntry : CNC_PARAM_LABELS.entrySet()) {
|
|
|
+ String code = labelEntry.getKey();
|
|
|
Map<String, Object> item = new LinkedHashMap<>();
|
|
|
- item.put("code", labelEntry.getKey());
|
|
|
+ item.put("code", CNC_PARAM_ADDRESSES.getOrDefault(code, code));
|
|
|
item.put("label", labelEntry.getValue());
|
|
|
- Object val = getParamValue(row, labelEntry.getKey());
|
|
|
- item.put("value", val != null ? val : "-");
|
|
|
- items.add(item);
|
|
|
- }
|
|
|
- for (Map.Entry<String, Object> entry : row.entrySet()) {
|
|
|
- String key = entry.getKey();
|
|
|
- if (CNC_PARAM_LABELS.containsKey(key) || CNC_PARAM_ALIASES.containsKey(key)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- Map<String, Object> item = new LinkedHashMap<>();
|
|
|
- item.put("code", key);
|
|
|
- item.put("label", key);
|
|
|
- item.put("value", entry.getValue());
|
|
|
+ item.put("value", formatParamValue(code, getParamValue(row, code)));
|
|
|
items.add(item);
|
|
|
}
|
|
|
return items;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 按主代码取值,同时兼容别名字段
|
|
|
+ * 按主代码取值,同时兼容别名字段;固定值参数优先返回固定值
|
|
|
*/
|
|
|
private Object getParamValue(JSONObject row, String code) {
|
|
|
- if (row == null || StringUtils.isBlank(code)) {
|
|
|
+ if (StringUtils.isBlank(code)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (CNC_PARAM_FIXED_VALUES.containsKey(code)) {
|
|
|
+ return CNC_PARAM_FIXED_VALUES.get(code);
|
|
|
+ }
|
|
|
+ if (row == null) {
|
|
|
return null;
|
|
|
}
|
|
|
Object val = row.get(code);
|
|
|
@@ -194,6 +217,35 @@ public class MesProductCncParamController extends BaseController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 格式化展示值:空值用 -;液压/气压转为 ON/OFF
|
|
|
+ */
|
|
|
+ private Object formatParamValue(String code, Object val) {
|
|
|
+ if (CNC_PARAM_FIXED_VALUES.containsKey(code)) {
|
|
|
+ return CNC_PARAM_FIXED_VALUES.get(code);
|
|
|
+ }
|
|
|
+ if (val == null || "".equals(String.valueOf(val).trim())) {
|
|
|
+ return "-";
|
|
|
+ }
|
|
|
+ if (CNC_PARAM_ON_OFF.contains(code)) {
|
|
|
+ return toOnOff(val);
|
|
|
+ }
|
|
|
+ return val;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String toOnOff(Object val) {
|
|
|
+ String s = String.valueOf(val).trim();
|
|
|
+ if ("1".equals(s) || "true".equalsIgnoreCase(s) || "on".equalsIgnoreCase(s)
|
|
|
+ || "yes".equalsIgnoreCase(s) || "开".equals(s)) {
|
|
|
+ return "ON";
|
|
|
+ }
|
|
|
+ if ("0".equals(s) || "false".equalsIgnoreCase(s) || "off".equalsIgnoreCase(s)
|
|
|
+ || "no".equalsIgnoreCase(s) || "关".equals(s)) {
|
|
|
+ return "OFF";
|
|
|
+ }
|
|
|
+ return s;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 将别名字段归一到主代码,避免重复展示
|
|
|
*/
|
|
|
private void normalizeAliasKeys(List<JSONObject> paramRows) {
|
|
|
@@ -204,11 +256,25 @@ public class MesProductCncParamController extends BaseController {
|
|
|
for (Map.Entry<String, String> alias : CNC_PARAM_ALIASES.entrySet()) {
|
|
|
String aliasKey = alias.getKey();
|
|
|
String primaryKey = alias.getValue();
|
|
|
+ if (aliasKey.equals(primaryKey)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
if (row.get(primaryKey) == null && row.get(aliasKey) != null) {
|
|
|
row.put(primaryKey, row.get(aliasKey));
|
|
|
}
|
|
|
row.remove(aliasKey);
|
|
|
}
|
|
|
+ // 固定值参数写入展示值
|
|
|
+ for (Map.Entry<String, String> fixed : CNC_PARAM_FIXED_VALUES.entrySet()) {
|
|
|
+ row.put(fixed.getKey(), fixed.getValue());
|
|
|
+ }
|
|
|
+ // 布尔类参数统一为 ON/OFF,便于多行表格展示
|
|
|
+ for (String onOffCode : CNC_PARAM_ON_OFF) {
|
|
|
+ Object val = row.get(onOffCode);
|
|
|
+ if (val != null) {
|
|
|
+ row.put(onOffCode, toOnOff(val));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|