硬件故障解析
This commit is contained in:
parent
ee7d0aa643
commit
5a052ef69c
@ -16,6 +16,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.xhpc.pp.server.ChargingPileServer.REDIS;
|
||||
import static com.xhpc.pp.utils.security.HexUtils.toBits;
|
||||
|
||||
@Lazy
|
||||
@Component("RealtimeDataLogic")
|
||||
@ -23,6 +24,8 @@ public class RealtimeDataLogic implements ServiceLogic {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(RealtimeDataLogic.class);
|
||||
|
||||
private static final String[] hftable = {"急停按钮动作故障","无可用整流模块","出风口温度过高","交流防雷故障","交直流模块DC20通信中断","绝缘检测模块FC08通信中断","电度表通信中断","读卡器通信中断","RC10通信中断","风扇调速板故障","直流熔断器故障","高压接触器故障","门打开"};
|
||||
|
||||
@Override
|
||||
public ServiceResult service(ServiceParameter sp) throws Exception {
|
||||
|
||||
@ -37,18 +40,33 @@ public class RealtimeDataLogic implements ServiceLogic {
|
||||
String gunkey = "gun:".concat(pileNo).concat(gunId);
|
||||
Map<String, Object> cacheGun = REDIS.getCacheMap(gunkey);
|
||||
cacheGun.put("status", status);
|
||||
cacheGun.put("soc", realtimeData.getSoc());
|
||||
REDIS.setCacheMap(gunkey, cacheGun);
|
||||
String orderNo = realtimeData.getOrderNo();
|
||||
Map<String, Object> order = REDIS.getCacheMap(orderNo);
|
||||
List<RealtimeData> realtimeDataList = (List<RealtimeData>) order.get("realtimeDataList");
|
||||
if (realtimeDataList == null) {
|
||||
realtimeDataList = new ArrayList<>();
|
||||
if (orderNo.equals("00000000000000000000000000000000")) {
|
||||
// todo
|
||||
String hardwareFault = realtimeData.getHardwareFault();
|
||||
String hfs = toBits(hardwareFault);
|
||||
char[] hfcs = hfs.toCharArray();
|
||||
String hfsplain = "";
|
||||
for (int i = hfcs.length-1; i >=0; i--) {
|
||||
if (hfcs[i] == 49) {
|
||||
hfsplain = hfsplain.concat(hftable[hfcs.length-i-1]).concat("!");
|
||||
}
|
||||
}
|
||||
cacheGun.put("hf", hfsplain);
|
||||
} else {
|
||||
String orderkey = "order:".concat(orderNo);
|
||||
Map<String, Object> order = REDIS.getCacheMap(orderkey);
|
||||
List<RealtimeData> realtimeDataList = (List<RealtimeData>) order.get("realtimeDataList");
|
||||
if (realtimeDataList == null) {
|
||||
realtimeDataList = new ArrayList<>();
|
||||
}
|
||||
realtimeDataList.add(realtimeData);
|
||||
order.put("soc", realtimeData.getSoc());
|
||||
order.put("status", status);
|
||||
order.put("realtimeDataList", realtimeDataList);
|
||||
REDIS.setCacheMap(orderkey, order);
|
||||
}
|
||||
realtimeDataList.add(realtimeData);
|
||||
order.put("status", status);
|
||||
order.put("realtimeDataList", realtimeDataList);
|
||||
REDIS.setCacheMap(orderNo, order);
|
||||
return new ServiceResult(false);
|
||||
}
|
||||
|
||||
|
||||
@ -166,12 +166,25 @@ public class HexUtils {
|
||||
return res;
|
||||
}
|
||||
|
||||
public static String toBits(String hex) {
|
||||
|
||||
byte[] bytes = toBytes(hex);
|
||||
final StringBuilder result = new StringBuilder();
|
||||
for (byte b: bytes) {
|
||||
for (int i=0; i<8; i++) {
|
||||
result. append((int)(b >> (8-(i+1)) & 0x0001));
|
||||
}
|
||||
}
|
||||
return result. toString();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
byte[] data1 = toBytes(reverseHex("A0860100"));
|
||||
System.out.println(toInteger(data1, 0, 4));
|
||||
System.out.println(reverseHexInt("A0860100"));
|
||||
System.out.println(toHexInt(100000));
|
||||
// byte[] data1 = toBytes(reverseHex("A0860100"));
|
||||
// System.out.println(toInteger(data1, 0, 4));
|
||||
// System.out.println(reverseHexInt("A0860100"));
|
||||
// System.out.println(toHexInt(100000));
|
||||
System.out.println(toBits("1000"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user