From 29ea56cf0546726a83da815ee6721090311f5567 Mon Sep 17 00:00:00 2001 From: zhoushihao <zsh19950802@163.com> Date: 星期四, 18 四月 2024 14:09:37 +0800 Subject: [PATCH] fixbug:代码误删版本回退 --- hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/common/PlcBitObject.java | 141 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 141 insertions(+), 0 deletions(-) diff --git a/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/common/PlcBitObject.java b/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/common/PlcBitObject.java new file mode 100644 index 0000000..4bd20de --- /dev/null +++ b/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/common/PlcBitObject.java @@ -0,0 +1,141 @@ +package com.mes.common; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +public class PlcBitObject { + + // 璇ユā鍧楁暟鎹被鍨嬶紝鏁版嵁璧峰浣嶇疆 + private String plcAddressBegin; + // 鏁版嵁鍦板潃闀垮害锛氱涓�鍙傛暟鍒版渶鍚庝竴涓弬鏁扮殑闀垮害 + private int plcAddressLength; + private ArrayList<PlcBitInfo> plcBitList; + + /** + * @return 鏁版嵁鍖哄紑濮嬪湴鍧� + */ + public String getPlcAddressBegin() { + return plcAddressBegin; + } + + /** + * @param plcAddressBegin 璁剧疆鏁版嵁鍖哄紑濮嬪湴鍧� + */ + public void setPlcAddressBegin(String plcAddressBegin) { + this.plcAddressBegin = plcAddressBegin; + } + + /** + * @return 鏁版嵁鍖� 璇诲彇鎵�鏈夋暟鎹墍闇�鐨勯暱搴︼紙浠yte绫诲瀷涓哄熀鍑嗭級 + */ + public int getPlcAddressLength() { + return plcAddressLength; + } + + /** + * @return 璁剧疆锛氭暟鎹尯 璇诲彇鎵�鏈夋暟鎹墍闇�鐨勯暱搴︼紙浠yte绫诲瀷涓哄熀鍑嗭級 + */ + public void setPlcAddressLength(int plcAddressLength) { + this.plcAddressLength = plcAddressLength; + } + + /** + * @return 鑾峰彇鍙傛暟瀹炰緥闆嗗悎 + */ + public ArrayList<PlcBitInfo> getBitList() { + return plcBitList; + } + + /** + * 鏍规嵁鍙傛暟鏍囪瘑 鑾峰彇鏌愪釜鍙傛暟瀹炰緥 + * + * @param codeid 鍙傛暟鏍囪瘑 + * @return 鑾峰彇鏌愪釜鍙傛暟瀹炰緥 + */ + public PlcBitInfo getPlcBit(String codeid) { + if (plcBitList != null) { + for (PlcBitInfo plcbitInfo : plcBitList) { + if (plcbitInfo.getCodeId().equals(codeid)) + return plcbitInfo; + } + return null; + } else + return null; + } + + /** + * 鏍规嵁鍙傛暟鏍囪瘑 鑾峰彇鏌愪釜鍙傛暟瀹炰緥 + * + * @param codeid 鍙傛暟鏍囪瘑 + * @return 鑾峰彇鏌愪釜鍙傛暟瀹炰緥 + */ + public List<Boolean> getPlcBitValues(List<String> codeids) { + List<Boolean> arrayList = new ArrayList<>(); + if (plcBitList != null) { + Map<String, Boolean> resultMap = new LinkedHashMap<>(); // 浣跨敤 LinkedHashMap 淇濈暀鎻掑叆椤哄簭 + for (PlcBitInfo plcBitInfo : plcBitList) { + if (codeids.contains(plcBitInfo.getCodeId().toString())) { + resultMap.put(plcBitInfo.getCodeId().toString(), plcBitInfo.getValue()); + } + } + for (String codeId : codeids) { // 鎸夌収浼犲叆鍙傛暟鐨勯『搴忛亶鍘� + Boolean value = resultMap.get(codeId); + if (value != null) { + arrayList.add(value); + } else { + arrayList.add(null); // 濡傛灉鎵句笉鍒板搴旂殑鍊硷紝娣诲姞 null + } + } + } + return arrayList; + } + + + public List<String> getAddressListByCodeId(List<String> codeIdList) { + List<String> addressList = new ArrayList<>(); + for (String codeId : codeIdList) { + for (PlcBitInfo plcBitInfo : plcBitList) { + if (plcBitInfo.getCodeId().equals(codeId)) { + int index = plcBitInfo.getAddressIndex(); + String address = plcBitInfo.getAddress(index); + if (address != null) { + addressList.add(address); + } + } + } + } + return addressList; + } + + + /** + * 娣诲姞鍙傛暟瀹炰緥 + * + * @param param 鍙傛暟瀹炰緥 + */ + public void addPlcBit(PlcBitInfo param) { + if (plcBitList != null) + plcBitList.add(param); + else { + plcBitList = new ArrayList<PlcBitInfo>(); + plcBitList.add(param); + } + } + + /** + * 鏍规嵁PLC杩斿洖鐨勬暟鎹� 缁欏弬鏁板疄渚嬭祴鍊� + * + * @param plcValueArray PLC璇诲彇鍥炴潵鐨刡yte绫诲瀷鏁版嵁闆嗗悎 + */ + public void setPlcBitList(List<Boolean> plcValueArray) { + if (plcBitList != null) { + for (PlcBitInfo plcbitInfo : plcBitList) { + plcbitInfo.setValue(plcValueArray.get(plcbitInfo.getAddressIndex())); + } + } + } + + +} \ No newline at end of file -- Gitblit v1.8.0