mirror of
https://github.com/hpd840321/starRiverProperty.git
synced 2026-06-10 00:40:30 +08:00
fix: relocate cwos-portal decompiled output to correct path; remove nested directory
Former-commit-id: dc30d42a8c55ed8b2382a41dc2434233fbed9930
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package cn.cloudwalk.elevator.util;
|
||||
|
||||
public class AcsCacheKeyUtil {
|
||||
public static String getOpenDoorCountKey(String date, String businessId) {
|
||||
return "elevator:passCount:" + date + ":" + businessId;
|
||||
}
|
||||
|
||||
public static String getRecogCountKey(String date, String businessId) {
|
||||
return "acs_recogCount_" + date + "_" + businessId;
|
||||
}
|
||||
|
||||
public static String getBackendRegLogIdKey(String deviceCode, String businessId, String captureId) {
|
||||
return "acs:backendRegLogId:" + deviceCode + "_" + businessId + "_" + captureId;
|
||||
}
|
||||
|
||||
public static String getBackendRegExpireKey(String businessId, String openDoorLogId) {
|
||||
return "acs:backendRegExpire:#" + businessId + "#" + openDoorLogId;
|
||||
}
|
||||
}
|
||||
|
||||
+999
@@ -0,0 +1,999 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* org.springframework.util.Assert
|
||||
* org.springframework.util.MultiValueMap
|
||||
*/
|
||||
package cn.cloudwalk.elevator.util;
|
||||
|
||||
import cn.cloudwalk.elevator.util.StringUtils;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.AbstractList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
public class CollectionUtils {
|
||||
private static final int HASH_MAP_DEFAULT_INITIAL_CAPACITY = 16;
|
||||
private static final float HASH_MAP_DEFAULT_LOAD_FACTOR = 0.75f;
|
||||
|
||||
public static <E> E getFirst(Collection<E> c) {
|
||||
if (c == null) {
|
||||
return null;
|
||||
}
|
||||
if (c instanceof List) {
|
||||
List list = (List)c;
|
||||
return list.isEmpty() ? null : (E)list.get(0);
|
||||
}
|
||||
if (c instanceof Set) {
|
||||
return c.isEmpty() ? null : (E)c.iterator().next();
|
||||
}
|
||||
if (c instanceof Queue) {
|
||||
return c.isEmpty() ? null : (E)((Queue)c).peek();
|
||||
}
|
||||
return c.isEmpty() ? null : (E)c.iterator().next();
|
||||
}
|
||||
|
||||
public static List<String> removeList(List<String> listA, List<String> listB) {
|
||||
HashSet<String> hs1 = new HashSet<String>(listA);
|
||||
HashSet<String> hs2 = new HashSet<String>(listB);
|
||||
hs1.removeAll(hs2);
|
||||
ArrayList<String> listC = new ArrayList<String>();
|
||||
listC.addAll(hs1);
|
||||
return listC;
|
||||
}
|
||||
|
||||
public static <E> List<List<E>> split(List<E> list, E element) {
|
||||
if (list == null) {
|
||||
return new ArrayList<List<E>>(0);
|
||||
}
|
||||
ArrayList<List<ArrayList<E>>> result = new ArrayList<List<ArrayList<E>>>();
|
||||
int start = 0;
|
||||
int end = 0;
|
||||
for (E e : list) {
|
||||
if (element == null ? e == null : element.equals(e)) {
|
||||
result.add(new ArrayList<E>(list.subList(start, end)));
|
||||
start = end + 1;
|
||||
}
|
||||
++end;
|
||||
}
|
||||
if (start == list.size()) {
|
||||
result.add(new ArrayList(0));
|
||||
} else if (start < list.size()) {
|
||||
result.add(new ArrayList<E>(list.subList(start, list.size())));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <E> List<List<E>> split(List<E> list, int ... index) {
|
||||
if (list == null) {
|
||||
return new ArrayList<List<E>>(0);
|
||||
}
|
||||
if (index == null || index.length == 0) {
|
||||
ArrayList<List<ArrayList<E>>> arrayList = new ArrayList<List<ArrayList<E>>>();
|
||||
arrayList.add(new ArrayList<E>(list));
|
||||
return arrayList;
|
||||
}
|
||||
if (index.length > list.size()) {
|
||||
throw new IllegalArgumentException("{index}\u6570\u91cf\u4e0d\u80fd\u5927\u4e8e{list}\u957f\u5ea6\u3002");
|
||||
}
|
||||
ArrayList<List<ArrayList<E>>> result = new ArrayList<List<ArrayList<E>>>();
|
||||
int temp = 0;
|
||||
for (int i : index) {
|
||||
if (i < temp) {
|
||||
throw new IllegalArgumentException("{index}\u7684\u6bcf\u4e2a\u503c\u5fc5\u987b\u6bd4\u524d\u4e00\u4e2a\u5927\u3002");
|
||||
}
|
||||
if (i > list.size()) {
|
||||
throw new IllegalArgumentException("{index}\u503c\u4e0d\u80fd\u5927\u4e8e{list}\u957f\u5ea6\u3002");
|
||||
}
|
||||
result.add(new ArrayList<E>(list.subList(temp, i)));
|
||||
temp = i;
|
||||
}
|
||||
if (temp == list.size()) {
|
||||
result.add(new ArrayList(0));
|
||||
} else if (temp < list.size()) {
|
||||
result.add(new ArrayList<E>(list.subList(temp, list.size())));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <T> List<T> wrap(final T[] array) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
}
|
||||
return new AbstractList<T>(){
|
||||
|
||||
@Override
|
||||
public T get(int index) {
|
||||
return array[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return array.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T set(int index, T element) {
|
||||
Object old = array[index];
|
||||
array[index] = element;
|
||||
return old;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int indexOf(Object o) {
|
||||
if (o == null) {
|
||||
for (int i = 0; i < array.length; ++i) {
|
||||
if (null != array[i]) continue;
|
||||
return i;
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < array.length; ++i) {
|
||||
if (!o.equals(array[i])) continue;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int lastIndexOf(Object o) {
|
||||
if (o == null) {
|
||||
for (int i = array.length - 1; i > -1; --i) {
|
||||
if (null != array[i]) continue;
|
||||
return i;
|
||||
}
|
||||
} else {
|
||||
for (int i = array.length - 1; i > -1; --i) {
|
||||
if (!o.equals(array[i])) continue;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> c) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> c) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static <T> List<T> values(Map<?, T> map) {
|
||||
if (map == null) {
|
||||
return null;
|
||||
}
|
||||
ArrayList<T> list = new ArrayList<T>(map.size());
|
||||
for (T t : map.values()) {
|
||||
list.add(t);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static <T> List<T> keys(Map<T, ?> map) {
|
||||
if (map == null) {
|
||||
return null;
|
||||
}
|
||||
ArrayList<T> list = new ArrayList<T>(map.size());
|
||||
for (T t : map.keySet()) {
|
||||
list.add(t);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static <E> int countOccurrence(E element, Iterable<E> elements) {
|
||||
if (elements == null) {
|
||||
return 0;
|
||||
}
|
||||
int i = 0;
|
||||
if (element == null) {
|
||||
for (E e : elements) {
|
||||
if (null != e) continue;
|
||||
++i;
|
||||
}
|
||||
} else {
|
||||
for (E e : elements) {
|
||||
if (!element.equals(e)) continue;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public static <E> E[] toArray(Collection<E> collection, Class<E> typeClass) {
|
||||
Object[] t = (Object[])Array.newInstance(typeClass, collection.size());
|
||||
int i = 0;
|
||||
Iterator<E> iterator = collection.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
t[i] = iterator.next();
|
||||
++i;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
public static <E> Iterator<E> iterator(final Enumeration<E> enumeration) {
|
||||
return new Iterator<E>(){
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return enumeration.hasMoreElements();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E next() {
|
||||
if (!this.hasNext()) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
return enumeration.nextElement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException("\u8be5\u8fed\u4ee3\u5668\u6ca1\u6709\u6307\u5411\u7684\u96c6\u5408\uff0c\u6240\u4ee5\u79fb\u9664\u5143\u7d20\u4e3a\u4e0d\u652f\u6301\u7684\u64cd\u4f5c\u3002");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static <E> Enumeration<E> enumeration(final Iterator<E> iterator) {
|
||||
return new Enumeration<E>(){
|
||||
|
||||
@Override
|
||||
public boolean hasMoreElements() {
|
||||
return iterator.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E nextElement() {
|
||||
return iterator.next();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static <T> void add(Collection<T> collection, Object value) {
|
||||
if (value == null) {
|
||||
collection.add(null);
|
||||
} else if (value.getClass().isArray()) {
|
||||
if (value instanceof Object[]) {
|
||||
for (Object o : (Object[])value) {
|
||||
collection.add(o);
|
||||
}
|
||||
} else {
|
||||
int length = Array.getLength(value);
|
||||
for (int i = 0; i < length; ++i) {
|
||||
collection.add(Array.get(value, i));
|
||||
}
|
||||
}
|
||||
} else if (value instanceof Collection || value instanceof Stack) {
|
||||
for (Object object : (Iterable)value) {
|
||||
collection.add(object);
|
||||
}
|
||||
} else if (value instanceof Iterator) {
|
||||
Iterator iterator = (Iterator)value;
|
||||
while (iterator.hasNext()) {
|
||||
collection.add(iterator.next());
|
||||
}
|
||||
} else {
|
||||
collection.add(value);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> void push(Stack<T> stack, Object value) {
|
||||
if (value == null) {
|
||||
stack.push(null);
|
||||
} else if (value.getClass().isArray()) {
|
||||
if (value instanceof Object[]) {
|
||||
for (Object o : (Object[])value) {
|
||||
stack.push(o);
|
||||
}
|
||||
} else {
|
||||
int length = Array.getLength(value);
|
||||
for (int i = 0; i < length; ++i) {
|
||||
stack.push(Array.get(value, i));
|
||||
}
|
||||
}
|
||||
} else if (value instanceof Collection || value instanceof Stack) {
|
||||
for (Object object : (Iterable)value) {
|
||||
stack.push(object);
|
||||
}
|
||||
} else {
|
||||
stack.push(value);
|
||||
}
|
||||
}
|
||||
|
||||
public static <K, V> MultiValueMap<K, V> synchronizedMultiValueMap(MultiValueMap<K, V> multiValueMap) {
|
||||
if (multiValueMap == null) {
|
||||
throw new IllegalArgumentException("The input argument is null!");
|
||||
}
|
||||
return new SynchronizedMultiValueMap<K, V>(multiValueMap);
|
||||
}
|
||||
|
||||
public static <K, V> MultiValueMap<K, V> unmodifiableMultiValueMap(MultiValueMap<? extends K, ? extends V> multiValueMap) {
|
||||
if (multiValueMap == null) {
|
||||
throw new IllegalArgumentException("The input argument is null!");
|
||||
}
|
||||
return new UnmodifiableMultiValueMap<K, V>(multiValueMap);
|
||||
}
|
||||
|
||||
public static boolean isEmpty(Collection<?> collection) {
|
||||
return collection == null || collection.isEmpty();
|
||||
}
|
||||
|
||||
public static boolean isEmpty(Stack<?> stack) {
|
||||
return stack == null || stack.isEmpty();
|
||||
}
|
||||
|
||||
public static boolean isEmpty(Map<?, ?> map) {
|
||||
return map == null || map.isEmpty();
|
||||
}
|
||||
|
||||
public static boolean isNotEmpty(Collection<?> collection) {
|
||||
return collection != null && !collection.isEmpty();
|
||||
}
|
||||
|
||||
public static boolean isNotEmpty(Stack<?> stack) {
|
||||
return stack != null && !stack.isEmpty();
|
||||
}
|
||||
|
||||
public static boolean isNotEmpty(Map<?, ?> map) {
|
||||
return map != null && !map.isEmpty();
|
||||
}
|
||||
|
||||
private static boolean isComparable(List<?> list, List<?> compareList, int index) {
|
||||
if (CollectionUtils.isEmpty(list) || CollectionUtils.isEmpty(compareList)) {
|
||||
return false;
|
||||
}
|
||||
Assert.isTrue((index >= 0 && index < list.size() ? 1 : 0) != 0, (String)"{index} \u7684\u503c\u5fc5\u987b\u4ece0 \u81f3 list.size() - 1 \u4e4b\u95f4\u3002");
|
||||
return list.size() >= compareList.size();
|
||||
}
|
||||
|
||||
public static String[] toStringArray(Collection<?> collection) {
|
||||
if (collection == null) {
|
||||
return null;
|
||||
}
|
||||
String[] stringArray = new String[collection.size()];
|
||||
int i = 0;
|
||||
for (Object o : collection) {
|
||||
stringArray[i] = StringUtils.toString(o);
|
||||
++i;
|
||||
}
|
||||
return stringArray;
|
||||
}
|
||||
|
||||
public static <K, V> void putAllIfAbsent(Map<K, V> map, Map<? extends K, ? extends V> paramMap) {
|
||||
if (map == null || paramMap == null) {
|
||||
return;
|
||||
}
|
||||
for (Map.Entry<K, V> entry : paramMap.entrySet()) {
|
||||
if (map.containsKey(entry.getKey())) continue;
|
||||
map.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public static int calculateHashMapMinInitialCapacity(int size) {
|
||||
return CollectionUtils.calculateHashMapMinInitialCapacity(size, 0.75f, 16);
|
||||
}
|
||||
|
||||
public static int calculateHashMapMinInitialCapacity(int size, float loadFactor, int initlalCapcity) {
|
||||
return Math.max((int)((float)size / loadFactor) + 1, initlalCapcity);
|
||||
}
|
||||
|
||||
public static List<Integer> strArrayToList(String var) {
|
||||
ArrayList<Integer> list = new ArrayList<Integer>();
|
||||
for (String v : var.split(",")) {
|
||||
list.add(Integer.parseInt(v));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
static class UnmodifiableMultiValueMap<K, V>
|
||||
implements MultiValueMap<K, V>,
|
||||
Serializable {
|
||||
private static final long serialVersionUID = 7629840602579792180L;
|
||||
final MultiValueMap<K, V> multiValueMap;
|
||||
Set<Map.Entry<K, List<V>>> entrySet;
|
||||
Collection<List<V>> values;
|
||||
Set<K> keySet;
|
||||
Map<K, V> singleValueMap;
|
||||
|
||||
UnmodifiableMultiValueMap(MultiValueMap<? extends K, ? extends V> multiValueMap) {
|
||||
this.multiValueMap = multiValueMap;
|
||||
}
|
||||
|
||||
public void add(K key, V value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void addAll(K k, List<? extends V> list) {
|
||||
}
|
||||
|
||||
public void addAll(MultiValueMap<K, V> multiValueMap) {
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean containsKey(Object key) {
|
||||
return this.multiValueMap.containsKey(key);
|
||||
}
|
||||
|
||||
public boolean containsValue(Object value) {
|
||||
return this.multiValueMap.containsValue(value);
|
||||
}
|
||||
|
||||
public Set<Map.Entry<K, List<V>>> entrySet() {
|
||||
if (this.entrySet == null) {
|
||||
this.entrySet = Collections.unmodifiableSet(this.multiValueMap.entrySet());
|
||||
}
|
||||
return this.entrySet;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
return this.multiValueMap.equals(o);
|
||||
}
|
||||
|
||||
public List<V> get(Object key) {
|
||||
return (List)this.multiValueMap.get(key);
|
||||
}
|
||||
|
||||
public V getFirst(K key) {
|
||||
return (V)this.multiValueMap.getFirst(key);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.multiValueMap.hashCode();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.multiValueMap.isEmpty();
|
||||
}
|
||||
|
||||
public Set<K> keySet() {
|
||||
if (this.keySet == null) {
|
||||
this.keySet = Collections.unmodifiableSet(this.multiValueMap.keySet());
|
||||
}
|
||||
return this.keySet;
|
||||
}
|
||||
|
||||
public List<V> put(K key, List<V> value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void putAll(Map<? extends K, ? extends List<V>> t) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public List<V> remove(Object key) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void set(K key, V value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void setAll(Map<K, V> values) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Set<Map.Entry<K, V>> singleValueEntrySet() {
|
||||
return this.toSingleValueMap().entrySet();
|
||||
}
|
||||
|
||||
public Collection<V> singleValues() {
|
||||
return this.toSingleValueMap().values();
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return this.multiValueMap.size();
|
||||
}
|
||||
|
||||
public Map<K, V> toSingleValueMap() {
|
||||
if (this.singleValueMap == null) {
|
||||
this.singleValueMap = Collections.unmodifiableMap(this.multiValueMap.toSingleValueMap());
|
||||
}
|
||||
return this.singleValueMap;
|
||||
}
|
||||
|
||||
public Collection<List<V>> values() {
|
||||
if (this.values == null) {
|
||||
this.values = Collections.unmodifiableCollection(this.multiValueMap.values());
|
||||
}
|
||||
return this.values;
|
||||
}
|
||||
}
|
||||
|
||||
static class SynchronizedSet<E>
|
||||
extends SynchronizedCollection<E>
|
||||
implements Set<E> {
|
||||
private static final long serialVersionUID = 6982504952424781802L;
|
||||
|
||||
SynchronizedSet(Set<E> set) {
|
||||
super(set);
|
||||
}
|
||||
|
||||
SynchronizedSet(Set<E> set, Object mutex) {
|
||||
super(set, mutex);
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return this.collection.equals(o);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return this.collection.hashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class SynchronizedCollection<E>
|
||||
implements Collection<E>,
|
||||
Serializable {
|
||||
private static final long serialVersionUID = -7540724106974451779L;
|
||||
final Collection<E> collection;
|
||||
final Object mutex;
|
||||
|
||||
SynchronizedCollection(Collection<E> collection) {
|
||||
if (collection == null) {
|
||||
throw new IllegalArgumentException("The input argument is null!");
|
||||
}
|
||||
this.collection = collection;
|
||||
this.mutex = this;
|
||||
}
|
||||
|
||||
SynchronizedCollection(Collection<E> collection, Object mutex) {
|
||||
if (collection == null) {
|
||||
throw new IllegalArgumentException("The input argument is null!");
|
||||
}
|
||||
this.collection = collection;
|
||||
this.mutex = mutex;
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
@Override
|
||||
public int size() {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return this.collection.size();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return this.collection.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return this.collection.contains(o);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return this.collection.toArray();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
@Override
|
||||
public <T> T[] toArray(T[] a) {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return this.collection.toArray(a);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return this.collection.iterator();
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
@Override
|
||||
public boolean add(E o) {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return this.collection.add(o);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return this.collection.remove(o);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> coll) {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return this.collection.containsAll(coll);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends E> coll) {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return this.collection.addAll(coll);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> coll) {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return this.collection.removeAll(coll);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> coll) {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return this.collection.retainAll(coll);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
this.collection.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public String toString() {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return this.collection.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream s) throws IOException {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
s.defaultWriteObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class SynchronizedMultiValueMap<K, V>
|
||||
implements MultiValueMap<K, V> {
|
||||
final MultiValueMap<K, V> multiValueMap;
|
||||
final Object mutex;
|
||||
private transient Set<K> keySet = null;
|
||||
private transient Set<Map.Entry<K, List<V>>> entrySet;
|
||||
private transient Collection<List<V>> values;
|
||||
private transient Set<Map.Entry<K, V>> singleValueEntrySet;
|
||||
private transient Collection<V> singleValues;
|
||||
|
||||
SynchronizedMultiValueMap(MultiValueMap<K, V> multiValueMap) {
|
||||
if (multiValueMap == null) {
|
||||
throw new IllegalArgumentException("The input argument is null!");
|
||||
}
|
||||
this.multiValueMap = multiValueMap;
|
||||
this.mutex = this;
|
||||
}
|
||||
|
||||
SynchronizedMultiValueMap(MultiValueMap<K, V> multiValueMap, Object mutex) {
|
||||
if (multiValueMap == null) {
|
||||
throw new IllegalArgumentException("The input argument is null!");
|
||||
}
|
||||
this.multiValueMap = multiValueMap;
|
||||
this.mutex = mutex;
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public void add(K key, V value) {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
this.multiValueMap.add(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void addAll(K k, List<? extends V> list) {
|
||||
}
|
||||
|
||||
public void addAll(MultiValueMap<K, V> multiValueMap) {
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public void clear() {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
this.multiValueMap.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public boolean containsKey(Object key) {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return this.multiValueMap.containsKey(key);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public boolean containsValue(Object value) {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return this.multiValueMap.containsValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public Set<Map.Entry<K, List<V>>> entrySet() {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
if (this.entrySet == null) {
|
||||
this.entrySet = new SynchronizedSet<Map.Entry<K, List<V>>>(this.multiValueMap.entrySet(), this.mutex);
|
||||
}
|
||||
return this.entrySet;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public boolean equals(Object o) {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return this.multiValueMap.equals(o);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public List<V> get(Object key) {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return (List)this.multiValueMap.get(key);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public V getFirst(K key) {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return (V)this.multiValueMap.getFirst(key);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public int hashCode() {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return this.multiValueMap.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return this.multiValueMap.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public Set<K> keySet() {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
if (this.keySet == null) {
|
||||
this.keySet = new SynchronizedSet<K>(this.multiValueMap.keySet(), this.mutex);
|
||||
}
|
||||
return this.keySet;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public List<V> put(K key, List<V> value) {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return (List)this.multiValueMap.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public void putAll(Map<? extends K, ? extends List<V>> t) {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
this.multiValueMap.putAll(t);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public List<V> remove(Object key) {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return (List)this.multiValueMap.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public void set(K key, V value) {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
this.multiValueMap.set(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public void setAll(Map<K, V> values) {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
this.multiValueMap.setAll(values);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public int size() {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return this.multiValueMap.size();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public Map<K, V> toSingleValueMap() {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return this.multiValueMap.toSingleValueMap();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public Collection<List<V>> values() {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
if (this.values == null) {
|
||||
this.values = new SynchronizedCollection<List<V>>(this.multiValueMap.values(), this.mutex);
|
||||
}
|
||||
return this.values;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public String toString() {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
return this.multiValueMap.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream s) throws IOException {
|
||||
Object object = this.mutex;
|
||||
synchronized (object) {
|
||||
s.defaultWriteObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package cn.cloudwalk.elevator.util;
|
||||
|
||||
public class CommunityConstants {
|
||||
|
||||
public static interface Icc {
|
||||
public static final String ICC_RTSP_URL = "rtsp://%s:9090/dss/monitor/param?cameraid=%s%%24%s&substream=1";
|
||||
public static final String ICC_PLAYBACK_RTSP_URL = "rtsp://%s:9090/dss/playback/param?cameraid=%s%%24%s&substream=1&type=3";
|
||||
public static final String ICC_OUTSIDE_HLS_URL = "/live/cameraid/%s%%24%s/substream/1.m3u8";
|
||||
public static final String ICC_PLAYBACK_OUTSIDE_HLS_URL = "/vod/center/cameraid/%s%%24%s/substream/1";
|
||||
public static final int DEVICE_TYPE_NVR = 6;
|
||||
public static final int DEVICE_TYPE_IPC = 2;
|
||||
}
|
||||
|
||||
public static interface Dcr {
|
||||
public static final String HTTPS_PREFIX = "https://";
|
||||
public static final String MID_PART_DOWNLOAD_URL = "/object/download?pool=";
|
||||
public static final String MID_PART_UPLOAD_URL = "/object/upload/do?token=";
|
||||
public static final String MID_DOWNLOAD_FILE_URL = "/simple-file/download?pool=";
|
||||
public static final String MID_UPLOAD_FILE_URL = "/simple-file/upload/full?pool=";
|
||||
public static final String PARA_PATH = "&path=";
|
||||
public static final String PARA_SIZE = "&offset=0&size=";
|
||||
public static final String PARA_ID = "&id=";
|
||||
public static final String ID = "ID";
|
||||
public static final String AUTH_TYPE = "Basic ";
|
||||
public static final String AUTH = "authorization";
|
||||
public static final String POOL = "pool";
|
||||
public static final String TOKEN = "Token";
|
||||
public static final String ADDRESS = "Address";
|
||||
public static final String AUTH_SUFFIX = "/object/upload";
|
||||
public static final Integer MAX_DOWNLOAD_SIZE = 16000000;
|
||||
public static final String OFFSET = "&offset=";
|
||||
public static final String SIZE = "&size=";
|
||||
}
|
||||
|
||||
public static interface Dcs {
|
||||
public static final String DCS_URL_ID_FORMAT = "%s:%s@%s:2015?dcsID=";
|
||||
public static final String DCS_URL_FORMAT = "%s:%s@%s:2015";
|
||||
}
|
||||
|
||||
public static interface Data {
|
||||
public static final String MALE = "\u7537";
|
||||
public static final String FEMALE = "\u5973";
|
||||
public static final String ID = "id";
|
||||
public static final String CREATE_TIME = "createTime";
|
||||
public static final String LAST_UPDATE_TIME = "lastUpdateTime";
|
||||
public static final String REGISTER_PERSON_ID = "register_person_id";
|
||||
public static final String GRID_ID = "grid_id";
|
||||
public static final Integer TOP_VALUE = 1;
|
||||
public static final Integer NO_TOP_VALUE = 0;
|
||||
public static final Integer PUBLISH_STATUS_1 = 1;
|
||||
public static final Integer PUBLISH_STATUS_2 = 2;
|
||||
public static final Integer PUBLISH_STATUS_3 = 3;
|
||||
public static final String AGE = "age";
|
||||
public static final String SEX = "sex";
|
||||
public static final String COMMUNITY_ID = "community_id";
|
||||
public static final String VILLAGE_ID = "village_id";
|
||||
}
|
||||
|
||||
public static interface Redis {
|
||||
public static final String EVENT_CODE_INC_KEY = "EVENT_CODE:INC_KEY";
|
||||
public static final Integer EVENT_CODE_INC_MAX_VALUE = 9999;
|
||||
public static final String TF_BRAIN_ACCESS_TOKEN = "tfbrain_access_token";
|
||||
public static final String USER_TOKEN_KEY = "USER_TOKEN:%s";
|
||||
public static final String OUT_IN_IMAGE_STORE = "upOutInStore";
|
||||
public static final String AGREEMENT = "redis://";
|
||||
public static final String LOCK = "redisLock";
|
||||
public static final String OLD_AUTO_CREATE_SETTING = "OLD:AUTO_CREATE";
|
||||
public static final String CHILD_AUTO_CREATE_SETTING = "CHILD:AUTO_CREATE:%s";
|
||||
public static final String IMPORT_FAILURE_MSG = "IMPORT:FAILURE:%s";
|
||||
public static final String VILLAGE_RECORD_LIST = "village:list";
|
||||
public static final String COMMUNITY_LIST = "community:list";
|
||||
public static final Long VALUE_CHANGE_EXPIRE_TIME = 1L;
|
||||
public static final String PROVINCE_TREE = "tree:province:level:%s";
|
||||
}
|
||||
|
||||
public static interface Alarm {
|
||||
public static final Integer IN = 1;
|
||||
public static final Integer OUT = 0;
|
||||
public static final String STRANGER = "STRANGER";
|
||||
public static final String BLACK_LIST = "BLACK_LIST";
|
||||
}
|
||||
|
||||
public static interface Symbol {
|
||||
public static final String COMMA = ",";
|
||||
public static final String HYPHEN = "-";
|
||||
public static final String COLON = ":";
|
||||
}
|
||||
|
||||
public static interface Snap {
|
||||
public static final String IMG_DOWNLOAD_PARSE_ERROR = "img_download_parse_error";
|
||||
public static final String DATA_IMAGE_BASE64_HEAD = "data:image/";
|
||||
}
|
||||
|
||||
public static interface Common {
|
||||
public static final String NOTE_TYPE_ORG = "1";
|
||||
public static final String NOTE_TYPE_TAG = "2";
|
||||
public static final String NOTE_TYPE_PERSON = "3";
|
||||
public static final String NOTE_TYPE_EDG = "4";
|
||||
public static final String ACCESS_NAME_SUFFIX = "\u95e8\u7981";
|
||||
public static final Integer ACCESS_AUTO = 0;
|
||||
public static final Integer ONE_HUNDRED = 100;
|
||||
public static final Integer BATCH_SIZE = 500;
|
||||
public static final Integer MAX_SHOW_CAPTURE = 7;
|
||||
public static final String TEMP_PATH = "java.io.tmpdir";
|
||||
public static final String FONT_PATH = "font/simsun.ttc";
|
||||
public static final String TEMPLATE_NAME = "appraiseReportTemplate";
|
||||
public static final String FONT_SUFFIX = ".ttc";
|
||||
public static final String DASH = "-";
|
||||
public static final String HTTP_PREFIX = "http://";
|
||||
public static final String BR = "<br/>";
|
||||
public static final String FORMAT = "yyyy/MM/dd/HH";
|
||||
public static final String CLIENT_IP = "ClientIP";
|
||||
}
|
||||
}
|
||||
|
||||
+416
@@ -0,0 +1,416 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* org.slf4j.Logger
|
||||
* org.slf4j.LoggerFactory
|
||||
*/
|
||||
package cn.cloudwalk.elevator.util;
|
||||
|
||||
import cn.cloudwalk.elevator.util.StartTimeAndEndTime;
|
||||
import java.security.Timestamp;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.temporal.ChronoField;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
import java.time.temporal.WeekFields;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class DateUtils {
|
||||
private static final Logger logger = LoggerFactory.getLogger(DateUtils.class);
|
||||
public static final long ONE_DAY_LONG = 86400000L;
|
||||
public static final String YYYYMMDD = "yyyyMMdd";
|
||||
public static final String STANDARD_FORMAT = "yyyy-MM-dd HH:mm";
|
||||
public static final String YYYY_MM_DD = "yyyy-MM-dd";
|
||||
public static final String YYYY_MM_DD_HMS = "yyyy-MM-dd HH:mm:ss";
|
||||
public static final String HHMMSS = "HH:mm:ss";
|
||||
public static final String YYYYMM = "yyyyMM";
|
||||
public static final String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
|
||||
|
||||
public static long getCurrentTime() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public static String timestamp2String(Timestamp time, String pattern) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
|
||||
return sdf.format(time.getTimestamp());
|
||||
}
|
||||
|
||||
public static String formatDate(Date date, String pattern) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
|
||||
return sdf.format(date);
|
||||
}
|
||||
|
||||
public static int defaultFormat(Date date) {
|
||||
return Integer.valueOf(DateUtils.formatDate(date, YYYYMMDD));
|
||||
}
|
||||
|
||||
public static Date defaultFormat(String str) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(YYYYMMDD);
|
||||
try {
|
||||
return sdf.parse(str);
|
||||
}
|
||||
catch (ParseException e) {
|
||||
logger.error("\u65e5\u671f\u683c\u5f0f\u8f6c\u6362\u5931\u8d25", (Throwable)e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Date customFormat(String str, String pattern) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
|
||||
try {
|
||||
return sdf.parse(str);
|
||||
}
|
||||
catch (ParseException e) {
|
||||
logger.error("\u65e5\u671f\u683c\u5f0f\u8f6c\u6362\u5931\u8d25", (Throwable)e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static int defaultFormat(long millis) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeInMillis(millis);
|
||||
return DateUtils.defaultFormat(cal.getTime());
|
||||
}
|
||||
|
||||
public static String parseTimestamp(Timestamp time) {
|
||||
return DateUtils.parseDate(time.getTimestamp());
|
||||
}
|
||||
|
||||
public static String parseDate(Date date) {
|
||||
try {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(YYYYMMDD);
|
||||
return sdf.format(date);
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("\u65e5\u671f\u683c\u5f0f\u8f6c\u6362\u5931\u8d25", (Throwable)e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String parseDate(Date date, String partern) {
|
||||
try {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(partern);
|
||||
return sdf.format(date);
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("\u65e5\u671f\u683c\u5f0f\u8f6c\u6362\u5931\u8d25", (Throwable)e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getYear() {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(new Date());
|
||||
return cal.get(1);
|
||||
}
|
||||
|
||||
public static long getMonthFirstDate(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(5, 1);
|
||||
calendar.set(11, 0);
|
||||
calendar.set(12, 0);
|
||||
calendar.set(13, 0);
|
||||
calendar.set(14, 0);
|
||||
return calendar.getTime().getTime();
|
||||
}
|
||||
|
||||
public static long getMonthLastDate(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(5, calendar.getActualMaximum(5));
|
||||
calendar.set(11, 23);
|
||||
calendar.set(12, 59);
|
||||
calendar.set(13, 59);
|
||||
calendar.set(14, 999);
|
||||
return calendar.getTime().getTime();
|
||||
}
|
||||
|
||||
public static Long dateToStamp(String s) {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(YYYYMMDD);
|
||||
try {
|
||||
Date date = simpleDateFormat.parse(s);
|
||||
long ts = date.getTime();
|
||||
return ts;
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("\u65e5\u671f\u8f6c\u4e3a\u65f6\u95f4\u6233\u5931\u8d25", (Throwable)e);
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
public static String stampToDate(String s) {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(YYYY_MM_DD_HMS);
|
||||
long lt = new Long(s);
|
||||
Date date = new Date(lt);
|
||||
String res = simpleDateFormat.format(date);
|
||||
return res;
|
||||
}
|
||||
|
||||
public static String getTwoDaysDesc(Integer startTime, Integer endTime) {
|
||||
ArrayList<Integer> days = new ArrayList<Integer>();
|
||||
if (null == startTime || null == endTime) {
|
||||
return "\u65e5";
|
||||
}
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(YYYYMMDD);
|
||||
try {
|
||||
Date start = dateFormat.parse(String.valueOf(startTime));
|
||||
Date end = dateFormat.parse(String.valueOf(endTime));
|
||||
Calendar tempStart = Calendar.getInstance();
|
||||
tempStart.setTime(start);
|
||||
Calendar tempEnd = Calendar.getInstance();
|
||||
tempEnd.setTime(end);
|
||||
tempEnd.add(5, 1);
|
||||
while (tempStart.before(tempEnd)) {
|
||||
days.add(Integer.parseInt(dateFormat.format(tempStart.getTime())));
|
||||
tempStart.add(6, 1);
|
||||
}
|
||||
}
|
||||
catch (ParseException e) {
|
||||
logger.error("\u65f6\u95f4\u8f6c\u6362\u5931\u8d25", (Throwable)e);
|
||||
}
|
||||
int dayOfWeek = 7;
|
||||
String twoDayDesc = days.size() > dayOfWeek ? "\u6708" : (days.size() > 1 ? "\u5468" : "\u65e5");
|
||||
return twoDayDesc;
|
||||
}
|
||||
|
||||
public static Long todayStart() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(11, 0);
|
||||
calendar.set(12, 0);
|
||||
calendar.set(13, 0);
|
||||
calendar.set(14, 0);
|
||||
return calendar.getTimeInMillis();
|
||||
}
|
||||
|
||||
public static Long dateToStampTomorrow(String s) {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(YYYYMMDD);
|
||||
try {
|
||||
Date date = simpleDateFormat.parse(s);
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.add(5, 1);
|
||||
long ts = cal.getTimeInMillis();
|
||||
return ts;
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("\u65e5\u671f\u8f6c\u6362\u5931\u8d25", (Throwable)e);
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
public static Date getDateSubDay(int day) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(new Date());
|
||||
cal.add(5, day);
|
||||
return cal.getTime();
|
||||
}
|
||||
|
||||
public static Date getDateSubDay(Date date, int day) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.add(5, day);
|
||||
return cal.getTime();
|
||||
}
|
||||
|
||||
public static Long todayStart(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(11, 0);
|
||||
calendar.set(12, 0);
|
||||
calendar.set(13, 0);
|
||||
calendar.set(14, 0);
|
||||
return calendar.getTimeInMillis();
|
||||
}
|
||||
|
||||
public static Long todayEnd(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(11, 23);
|
||||
calendar.set(12, 59);
|
||||
calendar.set(13, 59);
|
||||
calendar.set(14, 999);
|
||||
return calendar.getTimeInMillis();
|
||||
}
|
||||
|
||||
public static Long todayEnd() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(11, 23);
|
||||
calendar.set(12, 59);
|
||||
calendar.set(13, 59);
|
||||
calendar.set(14, 999);
|
||||
return calendar.getTimeInMillis();
|
||||
}
|
||||
|
||||
public static String formatTimeDuration(long duration, int format) {
|
||||
boolean fu = false;
|
||||
long fduration = duration;
|
||||
if (duration < 0L) {
|
||||
fu = true;
|
||||
fduration = Math.abs(duration);
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
long sec = fduration / 1000L % 60L;
|
||||
long min = fduration / 1000L / 60L % 60L;
|
||||
long hour = fduration / 1000L / 60L / 60L % 24L;
|
||||
long day = fduration / 1000L / 60L / 60L / 24L;
|
||||
if (day > 0L && format > 0) {
|
||||
--format;
|
||||
builder.append(day).append("\u5929");
|
||||
}
|
||||
if (hour > 0L && --format > 0) {
|
||||
builder.append(hour).append("\u5c0f\u65f6");
|
||||
}
|
||||
if (min > 0L && --format > 0) {
|
||||
builder.append(min).append("\u5206\u949f");
|
||||
}
|
||||
if (sec > 0L && --format > 0) {
|
||||
builder.append(sec).append("\u79d2");
|
||||
}
|
||||
if (fu) {
|
||||
builder.insert(0, "-");
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static String formatTimeDurationHour(long duration, int format) {
|
||||
if (duration == 0L) {
|
||||
return "-";
|
||||
}
|
||||
long fduration = Math.abs(duration);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
long sec = fduration / 1000L % 60L;
|
||||
long min = fduration / 1000L / 60L % 60L;
|
||||
long hour = fduration / 1000L / 60L / 60L;
|
||||
if (hour > 0L && format > 0) {
|
||||
builder.append(hour).append("\u5c0f\u65f6");
|
||||
}
|
||||
if (min > 0L && --format > 0) {
|
||||
builder.append(min).append("\u5206\u949f");
|
||||
}
|
||||
if (sec > 0L && --format > 0) {
|
||||
builder.append(sec).append("\u79d2");
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static Date getMonth(Date date, int count) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
int month = calendar.get(2);
|
||||
calendar.set(2, month - count);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
public static int getYear(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
return calendar.get(1);
|
||||
}
|
||||
|
||||
public static int getMonth(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
return calendar.get(2) + 1;
|
||||
}
|
||||
|
||||
public static Long dateToStampFormat(String s, String format) {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
|
||||
try {
|
||||
Date date = simpleDateFormat.parse(s);
|
||||
return date.getTime();
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("\u65e5\u671f\u8f6c\u6362\u5931\u8d25", (Throwable)e);
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean timeIsInRound(String now, String start, String end, String format) {
|
||||
Date endTime;
|
||||
Date beginTime;
|
||||
Date nowTime;
|
||||
SimpleDateFormat df = new SimpleDateFormat(format);
|
||||
try {
|
||||
nowTime = df.parse(now);
|
||||
beginTime = df.parse(start);
|
||||
endTime = df.parse(end);
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("\u65f6\u95f4\u683c\u5f0f\u8f6c\u6362\u5f02\u5e38,\u539f\u56e0=[{}]", (Object)e.getMessage(), (Object)e);
|
||||
return false;
|
||||
}
|
||||
return nowTime.getTime() >= beginTime.getTime() && nowTime.getTime() <= endTime.getTime();
|
||||
}
|
||||
|
||||
public static int getDayOfWeek(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
return calendar.get(7);
|
||||
}
|
||||
|
||||
public static LocalDateTime millToDate(Long mill) {
|
||||
return LocalDateTime.ofInstant(Instant.ofEpochMilli(mill), ZoneOffset.ofHours(8));
|
||||
}
|
||||
|
||||
public static List<StartTimeAndEndTime> getCycle(Integer timeType, int cycleNum) {
|
||||
if (timeType == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
ArrayList<StartTimeAndEndTime> timeList = new ArrayList<StartTimeAndEndTime>(cycleNum);
|
||||
switch (timeType) {
|
||||
case 0: {
|
||||
LocalDateTime nowStartTime = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
|
||||
LocalDateTime nowEndTime = LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
|
||||
timeList.add(new StartTimeAndEndTime(nowStartTime.toInstant(ZoneOffset.of("+8")).toEpochMilli(), nowEndTime.toInstant(ZoneOffset.of("+8")).toEpochMilli(), nowStartTime.getDayOfMonth() + "\u53f7"));
|
||||
for (int i = 1; i < cycleNum; ++i) {
|
||||
LocalDateTime firstDay = nowStartTime.minusDays(i);
|
||||
LocalDateTime lastDay = nowEndTime.minusDays(i);
|
||||
timeList.add(new StartTimeAndEndTime(firstDay.toInstant(ZoneOffset.of("+8")).toEpochMilli(), lastDay.toInstant(ZoneOffset.of("+8")).toEpochMilli(), firstDay.getDayOfMonth() + "\u53f7"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
LocalDateTime nowMonday = LocalDateTime.of(LocalDate.now(), LocalTime.MIN).with(DayOfWeek.MONDAY);
|
||||
LocalDateTime nowSunday = LocalDateTime.of(LocalDate.now(), LocalTime.MAX).with(DayOfWeek.SUNDAY);
|
||||
timeList.add(new StartTimeAndEndTime(nowMonday.toInstant(ZoneOffset.of("+8")).toEpochMilli(), nowSunday.toInstant(ZoneOffset.of("+8")).toEpochMilli(), nowMonday.get(WeekFields.ISO.weekOfWeekBasedYear()) + "\u5468"));
|
||||
for (int i = 1; i < cycleNum; ++i) {
|
||||
LocalDateTime lastMonday = nowMonday.minusWeeks(i);
|
||||
LocalDateTime lastSunday = nowSunday.minusWeeks(i);
|
||||
timeList.add(new StartTimeAndEndTime(lastMonday.toInstant(ZoneOffset.of("+8")).toEpochMilli(), lastSunday.toInstant(ZoneOffset.of("+8")).toEpochMilli(), lastMonday.get(WeekFields.ISO.weekOfWeekBasedYear()) + "\u5468"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
LocalDateTime nowFirstDay = LocalDateTime.of(LocalDate.now(), LocalTime.MIN).with(TemporalAdjusters.firstDayOfMonth());
|
||||
LocalDateTime nowLastDay = LocalDateTime.of(LocalDate.now(), LocalTime.MAX).with(TemporalAdjusters.lastDayOfMonth());
|
||||
timeList.add(new StartTimeAndEndTime(nowFirstDay.toInstant(ZoneOffset.of("+8")).toEpochMilli(), nowLastDay.toInstant(ZoneOffset.of("+8")).toEpochMilli(), nowFirstDay.get(ChronoField.MONTH_OF_YEAR) + "\u6708"));
|
||||
for (int i = 1; i < cycleNum; ++i) {
|
||||
LocalDateTime firstDay = LocalDateTime.now().minusMonths(i).with(TemporalAdjusters.firstDayOfMonth()).with(LocalTime.MIN);
|
||||
LocalDateTime lastDay = LocalDateTime.now().minusMonths(i).with(TemporalAdjusters.lastDayOfMonth()).with(LocalTime.MAX);
|
||||
timeList.add(new StartTimeAndEndTime(firstDay.toInstant(ZoneOffset.of("+8")).toEpochMilli(), lastDay.toInstant(ZoneOffset.of("+8")).toEpochMilli(), firstDay.get(ChronoField.MONTH_OF_YEAR) + "\u6708"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return timeList;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(">>>>>>>>>>>>>>" + DateUtils.dateToStampFormat("202002", YYYYMM));
|
||||
}
|
||||
}
|
||||
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.fasterxml.jackson.annotation.JsonInclude$Include
|
||||
* com.fasterxml.jackson.core.JsonProcessingException
|
||||
* com.fasterxml.jackson.core.type.TypeReference
|
||||
* com.fasterxml.jackson.databind.DeserializationFeature
|
||||
* com.fasterxml.jackson.databind.JavaType
|
||||
* com.fasterxml.jackson.databind.Module
|
||||
* com.fasterxml.jackson.databind.ObjectMapper
|
||||
* com.fasterxml.jackson.databind.SerializationFeature
|
||||
* com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
|
||||
* org.slf4j.Logger
|
||||
* org.slf4j.LoggerFactory
|
||||
*/
|
||||
package cn.cloudwalk.elevator.util;
|
||||
|
||||
import cn.cloudwalk.elevator.util.DateUtils;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.Module;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class JsonUtils {
|
||||
private static final Logger log = LoggerFactory.getLogger(JsonUtils.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(DateUtils.class);
|
||||
|
||||
public static String toJson(Object obj) {
|
||||
ObjectMapper mapper = JsonUtils.objectMapper();
|
||||
try {
|
||||
return mapper.writeValueAsString(obj);
|
||||
}
|
||||
catch (JsonProcessingException e) {
|
||||
logger.warn("json parase exception :{}", (Object)e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T toObj(String json, Class<T> clazz) {
|
||||
ObjectMapper mapper = JsonUtils.objectMapper();
|
||||
Object value = null;
|
||||
try {
|
||||
value = mapper.readValue(json, clazz);
|
||||
}
|
||||
catch (IOException e) {
|
||||
logger.warn("json parase exception :{}", (Object)e.getMessage());
|
||||
}
|
||||
return (T)value;
|
||||
}
|
||||
|
||||
public static <T> T toObj(String json, TypeReference<T> tTypeReference) {
|
||||
ObjectMapper mapper = JsonUtils.objectMapper();
|
||||
Object value = null;
|
||||
try {
|
||||
value = mapper.readValue(json, tTypeReference);
|
||||
}
|
||||
catch (IOException e) {
|
||||
logger.warn("json parase exception :{}", (Object)e.getMessage());
|
||||
}
|
||||
return (T)value;
|
||||
}
|
||||
|
||||
public static <T> List<T> toObjList(String json, Class<T> clazz) {
|
||||
ObjectMapper mapper = JsonUtils.objectMapper();
|
||||
List value = null;
|
||||
try {
|
||||
JavaType jt = mapper.getTypeFactory().constructParametricType(ArrayList.class, new Class[]{clazz});
|
||||
value = (List)mapper.readValue(json, jt);
|
||||
}
|
||||
catch (IOException e) {
|
||||
logger.warn("json parase exception :{}", (Object)e.getMessage());
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ObjectMapper objectMapper() {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.registerModule((Module)new JavaTimeModule());
|
||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
return mapper;
|
||||
}
|
||||
}
|
||||
|
||||
+194
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.fasterxml.jackson.annotation.JsonInclude$Include
|
||||
* com.fasterxml.jackson.core.type.TypeReference
|
||||
* com.fasterxml.jackson.databind.DeserializationFeature
|
||||
* com.fasterxml.jackson.databind.ObjectMapper
|
||||
* org.slf4j.Logger
|
||||
* org.slf4j.LoggerFactory
|
||||
* org.springframework.http.HttpEntity
|
||||
* org.springframework.http.HttpHeaders
|
||||
* org.springframework.http.HttpMethod
|
||||
* org.springframework.http.HttpStatus
|
||||
* org.springframework.http.ResponseEntity
|
||||
* org.springframework.http.client.ClientHttpRequestFactory
|
||||
* org.springframework.http.client.SimpleClientHttpRequestFactory
|
||||
* org.springframework.http.converter.HttpMessageConverter
|
||||
* org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
|
||||
* org.springframework.stereotype.Component
|
||||
* org.springframework.util.MultiValueMap
|
||||
* org.springframework.web.client.RestTemplate
|
||||
*/
|
||||
package cn.cloudwalk.elevator.util;
|
||||
|
||||
import cn.cloudwalk.elevator.util.DateUtils;
|
||||
import cn.cloudwalk.elevator.util.JsonUtils;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import javax.annotation.PostConstruct;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@Component
|
||||
public class RestTemplateUtil {
|
||||
private static final Logger logger = LoggerFactory.getLogger(DateUtils.class);
|
||||
private static RestTemplate restTemplate;
|
||||
|
||||
@PostConstruct
|
||||
public void getInstance() {
|
||||
RestTemplate restTemplate = SingletonRestTemplate.INSTANCE;
|
||||
List converterList = restTemplate.getMessageConverters();
|
||||
HttpMessageConverter converterTarget = null;
|
||||
for (HttpMessageConverter item : converterList) {
|
||||
if (MappingJackson2HttpMessageConverter.class != item.getClass()) continue;
|
||||
converterTarget = item;
|
||||
break;
|
||||
}
|
||||
if (null != converterTarget) {
|
||||
converterList.remove(converterTarget);
|
||||
}
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
converterList.add(new MappingJackson2HttpMessageConverter(objectMapper));
|
||||
RestTemplateUtil.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
public static String get(String url) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Accept", "application/json");
|
||||
headers.add("Content-Encoding", "UTF-8");
|
||||
headers.add("Content-Type", "application/json; charset=UTF-8");
|
||||
HttpEntity requestEntity = new HttpEntity(null, (MultiValueMap)headers);
|
||||
ResponseEntity response = restTemplate.exchange(url, HttpMethod.GET, requestEntity, String.class, new Object[0]);
|
||||
return (String)response.getBody();
|
||||
}
|
||||
|
||||
public static String get(URI url, HttpHeaders headers) {
|
||||
HttpEntity requestEntity = new HttpEntity(null, (MultiValueMap)headers);
|
||||
ResponseEntity response = restTemplate.exchange(url, HttpMethod.GET, requestEntity, String.class);
|
||||
return (String)response.getBody();
|
||||
}
|
||||
|
||||
public static <T> T get(URI url, HttpHeaders headers, Class<T> responseType) {
|
||||
HttpEntity requestEntity = new HttpEntity(null, (MultiValueMap)headers);
|
||||
T resultEntity = null;
|
||||
try {
|
||||
ResponseEntity result = restTemplate.exchange(url, HttpMethod.GET, requestEntity, responseType);
|
||||
resultEntity = RestTemplateUtil.getResultEntity(result, url);
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.warn(">>>>>>>>>>>>>>>>>\u3010{}\u3011\u63a5\u53e3\u8c03\u7528\u5931\u8d25\uff0c\u9519\u8bef\u4fe1\u606f", (Object)url, (Object)e);
|
||||
}
|
||||
return resultEntity;
|
||||
}
|
||||
|
||||
public static <T> T post(URI url, Object data, HttpHeaders headers, Class<T> responseType) {
|
||||
HttpEntity requestEntity = new HttpEntity(data, (MultiValueMap)headers);
|
||||
T resultEntity = null;
|
||||
try {
|
||||
logger.info(">>>>>>>>>>>>>>>>>\u5f00\u59cb\u8bf7\u6c42\u63a5\u53e3:{}\uff0cpayload:{},", (Object)url.toString(), data);
|
||||
ResponseEntity result = restTemplate.postForEntity(url, (Object)requestEntity, responseType);
|
||||
resultEntity = RestTemplateUtil.getResultEntity(result, url);
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.warn(">>>>>>>>>>>>>>>>>\u63a5\u53e3\u8c03\u7528\u5931\u8d25\uff0c\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
}
|
||||
return resultEntity;
|
||||
}
|
||||
|
||||
public static <T> T postTf(URI url, Object data, HttpHeaders headers, Class<T> responseType) throws Exception {
|
||||
HttpEntity requestEntity = new HttpEntity(data, (MultiValueMap)headers);
|
||||
T resultEntity = null;
|
||||
try {
|
||||
logger.info(">>>>>>>>>>>>>>>>>\u5f00\u59cb\u8bf7\u6c42\u63a5\u53e3:{},payload:{},", (Object)url.toString(), data);
|
||||
ResponseEntity result = restTemplate.postForEntity(url, (Object)requestEntity, responseType);
|
||||
resultEntity = RestTemplateUtil.getTfResultEntity(result, url);
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.warn(">>>>>>>>>>>>>>>>>\u63a5\u53e3\u8c03\u7528\u5931\u8d25\uff0c\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
return resultEntity;
|
||||
}
|
||||
|
||||
public static <T> T post(URI url, Object data, HttpHeaders headers, TypeReference<T> tTypeReference) {
|
||||
HttpEntity requestEntity = new HttpEntity(data, (MultiValueMap)headers);
|
||||
T resultEntity = null;
|
||||
try {
|
||||
ResponseEntity result = restTemplate.postForEntity(url, (Object)requestEntity, String.class);
|
||||
if (HttpStatus.OK == result.getStatusCode()) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("\u63a5\u53e3\u8fd4\u56de\u503c\uff1a{}", (Object)JsonUtils.toJson(result.getBody()));
|
||||
}
|
||||
return JsonUtils.toObj((String)result.getBody(), tTypeReference);
|
||||
}
|
||||
logger.info(">>>>>>>>>>>>>>>>>\u63a5\u53e3\u8c03\u7528\u5931\u8d25\uff0c\u72b6\u6001\u7801\uff1a{},\u9519\u8bef\u539f\u56e0\uff1a{}", (Object)result.getStatusCode(), (Object)JsonUtils.toJson(result.getBody()));
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.warn(">>>>>>>>>>>>>>>>>\u63a5\u53e3\u8c03\u7528\u5931\u8d25\uff0c\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
}
|
||||
return resultEntity;
|
||||
}
|
||||
|
||||
private static <T> T getTfResultEntity(ResponseEntity<T> result, URI url) throws Exception {
|
||||
HttpStatus statusCode = result.getStatusCode();
|
||||
if (HttpStatus.OK == statusCode) {
|
||||
logger.info(">>>>>>>>>>>>>>>>>\u63a5\u53e3:{} \u8c03\u7528\u6210\u529f", (Object)url);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("\u63a5\u53e3\u8fd4\u56de\u503c\uff1a{}", (Object)JsonUtils.toJson(result.getBody()));
|
||||
}
|
||||
return (T)result.getBody();
|
||||
}
|
||||
logger.info(">>>>>>>>>>>>>>>>>\u63a5\u53e3\u8c03\u7528\u5931\u8d25\uff0c\u72b6\u6001\u7801\uff1a{},\u9519\u8bef\u539f\u56e0\uff1a{}", (Object)statusCode, (Object)JsonUtils.toJson(result.getBody()));
|
||||
if (HttpStatus.UNAUTHORIZED == statusCode) {
|
||||
throw new Exception(statusCode.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static <T> T getResultEntity(ResponseEntity<T> result, URI url) {
|
||||
if (HttpStatus.OK == result.getStatusCode()) {
|
||||
logger.info(">>>>>>>>>>>>>>>>>\u63a5\u53e3:{} \u8c03\u7528\u6210\u529f", (Object)url);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("\u63a5\u53e3\u8fd4\u56de\u503c\uff1a{}", (Object)JsonUtils.toJson(result.getBody()));
|
||||
}
|
||||
return (T)result.getBody();
|
||||
}
|
||||
logger.info(">>>>>>>>>>>>>>>>>\u63a5\u53e3\u8c03\u7528\u5931\u8d25\uff0c\u72b6\u6001\u7801\uff1a{},\u9519\u8bef\u539f\u56e0\uff1a{}", (Object)result.getStatusCode(), (Object)JsonUtils.toJson(result.getBody()));
|
||||
return null;
|
||||
}
|
||||
|
||||
private static class SingletonRestTemplate {
|
||||
static SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
|
||||
static final RestTemplate INSTANCE;
|
||||
|
||||
private SingletonRestTemplate() {
|
||||
}
|
||||
|
||||
static {
|
||||
requestFactory.setConnectTimeout(10000);
|
||||
requestFactory.setReadTimeout(10000);
|
||||
INSTANCE = new RestTemplate((ClientHttpRequestFactory)requestFactory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package cn.cloudwalk.elevator.util;
|
||||
|
||||
public class StartTimeAndEndTime {
|
||||
private Long startTime;
|
||||
private Long endTime;
|
||||
private String currentTime;
|
||||
|
||||
public StartTimeAndEndTime(Long startTime, Long endTime, String currentTime) {
|
||||
this.startTime = startTime;
|
||||
this.endTime = endTime;
|
||||
this.currentTime = currentTime;
|
||||
}
|
||||
|
||||
public Long getStartTime() {
|
||||
return this.startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(Long startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public Long getEndTime() {
|
||||
return this.endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(Long endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public String getCurrentTime() {
|
||||
return this.currentTime;
|
||||
}
|
||||
|
||||
public void setCurrentTime(String currentTime) {
|
||||
this.currentTime = currentTime;
|
||||
}
|
||||
}
|
||||
|
||||
+2072
File diff suppressed because it is too large
Load Diff
+25
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package cn.cloudwalk.elevator.util;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class ToolUtil {
|
||||
private ToolUtil() {
|
||||
}
|
||||
|
||||
public static String generateUUID() {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
return uuid.replaceAll("-", "");
|
||||
}
|
||||
|
||||
public static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
|
||||
ConcurrentHashMap.KeySetView seen = ConcurrentHashMap.newKeySet();
|
||||
return t -> seen.add(keyExtractor.apply(t));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user