vin hex to char

This commit is contained in:
ZZ 2022-01-13 17:55:41 +08:00
parent 815da83f4e
commit c0981a9989
3 changed files with 21 additions and 8 deletions

View File

@ -170,29 +170,39 @@ public class HexUtils {
byte[] bytes = toBytes(hex); byte[] bytes = toBytes(hex);
final StringBuilder result = new StringBuilder(); final StringBuilder result = new StringBuilder();
for (byte b: bytes) { for (byte b : bytes) {
for (int i=0; i<8; i++) { for (int i = 0; i < 8; i++) {
result. append((int)(b >> (8-(i+1)) & 0x0001)); result.append(b >> (8 - (i + 1)) & 0x0001);
} }
} }
return result. toString(); return result.toString();
}
public static final String toAscii(String hex) {
if (hex == null) return null;
byte[] bytes = toBytes(hex);
StringBuilder sb = new StringBuilder();
for (byte b : bytes) {
sb.append(Character.valueOf((char) b));
}
return sb.toString();
} }
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(Long.valueOf(10L).toString()); // System.out.println(Long.valueOf(10L).toString());
// System.out.println(reverseHexInt("FF00")); // System.out.println(reverseHexInt("FF00"));
// byte[] data1 = toBytes(reverseHex("10270000")); // byte[] data1 = toBytes(reverseHex("10270000"));
// System.out.println(toInteger(data1, 0, 4)); // System.out.println(toInteger(data1, 0, 4));
System.out.println(reverseHexInt("D80E")); // System.out.println(reverseHexInt("D80E"));
System.out.println(toHexInt(3800)); // System.out.println(toHexInt(3800));
// System.out.println(toHexInt(100000)); // System.out.println(toHexInt(100000));
// System.out.println(toBits("1000")); // System.out.println(toBits("1000"));
// System.out.println(toHex(new byte[]{104, 13, 19, 123, 0, 3, 105, -123, 71, -123, -106, 50, 84, 1, 0, 72, 106, 104, // System.out.println(toHex(new byte[]{104, 13, 19, 123, 0, 3, 105, -123, 71, -123, -106, 50, 84, 1, 0, 72, 106, 104,
// -94, 19, 124, 0, 59, 105, -123, 71, -123, -106, 50, 84, 1, 33, 9, 24, 9, 67, 57, 0, 2, 105, -123, 71, -123, -106, // -94, 19, 124, 0, 59, 105, -123, 71, -123, -106, 50, 84, 1, 33, 9, 24, 9, 67, 57, 0, 2, 105, -123, 71, -123, -106,
// 50, 84, 1, -88, 97, 43, 9, 50, 9, 21, 48, 117, 50, 9, 50, 9, 21, -64, 87, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 50, 84, 1, -88, 97, 43, 9, 50, 9, 21, 48, 117, 50, 9, 50, 9, 21, -64, 87, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
// -40, 83, 1, 0})); // -40, 83, 1, 0}));
} }
} }

View File

@ -30,6 +30,7 @@ import static com.xhpc.pp.utils.security.CacheDataUtils.reflectTranslate;
public class OrderDataLogic implements ServiceLogic { public class OrderDataLogic implements ServiceLogic {
private static final Logger log = LoggerFactory.getLogger(OrderDataLogic.class); private static final Logger log = LoggerFactory.getLogger(OrderDataLogic.class);
@Autowired @Autowired
private PileOrderService pileOrderService; private PileOrderService pileOrderService;

View File

@ -40,6 +40,8 @@ public class CacheDataUtils {
} }
} else if (tarFieldName.contains("ime")) { } else if (tarFieldName.contains("ime")) {
tarval = DateUtil.format(cp56toDate(srcval), NORM_DATETIME_FORMAT); tarval = DateUtil.format(cp56toDate(srcval), NORM_DATETIME_FORMAT);
} else if (tarFieldName.startsWith("vin")) {
tarval = HexUtils.toAscii(srcval);
} else { } else {
tarval = srcval; tarval = srcval;
} }