From c6c9b7d3baa822765768c110304d27623f946286 Mon Sep 17 00:00:00 2001
From: pjb <123456>
Date: 星期二, 15 七月 2025 14:29:09 +0800
Subject: [PATCH] `1`
---
zy-asrs-wms/src/main/java/com/zy/asrs/wms/utils/Utils.java | 782 +++++++++++++++++++++++++++++++------------------------
1 files changed, 436 insertions(+), 346 deletions(-)
diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/utils/Utils.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/utils/Utils.java
index edeab46..4ba0084 100644
--- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/utils/Utils.java
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/utils/Utils.java
@@ -1,346 +1,436 @@
-package com.zy.asrs.wms.utils;
-
-
-import com.zy.asrs.framework.common.Cools;
-import com.zy.asrs.wms.common.constant.Constants;
-
-import javax.servlet.http.HttpServletResponse;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Optional;
-import java.util.function.BiConsumer;
-import java.util.function.Function;
-
-/**
- * Created by vincent on 2023/3/14
- */
-public class Utils {
-
- public static final String _LINK = "-";
-
- /**
- * 閫氳繃搴撲綅鍙疯幏鍙� 鎺�
- */
- public static int getRow(String locNo) {
- if (!Cools.isEmpty(locNo)) {
- String[] split = locNo.split(_LINK);
- return Integer.parseInt(split[0]);
- }
- throw new RuntimeException("搴撲綅瑙f瀽寮傚父");
- }
-
- /**
- * 閫氳繃搴撲綅鍙疯幏鍙� 鍒�
- */
- public static int getBay(String locNo) {
- if (!Cools.isEmpty(locNo)) {
- String[] split = locNo.split(_LINK);
- return Integer.parseInt(split[1]);
- }
- throw new RuntimeException("搴撲綅瑙f瀽寮傚父");
- }
-
- /**
- * 閫氳繃搴撲綅鍙疯幏鍙� 灞�
- */
- public static int getLev(String locNo) {
- if (!Cools.isEmpty(locNo)) {
- String[] split = locNo.split(_LINK);
- return Integer.parseInt(split[2]);
- }
- throw new RuntimeException("搴撲綅瑙f瀽寮傚父");
- }
-
- public static String getLocNo(Number row, Number bay, Number lev) {
- return row + _LINK + bay + _LINK + lev;
- }
-
- /**
- * List杞负鏍戝舰缁撴瀯
- *
- * @param data List
- * @param parentId 椤剁骇鐨刾arentId
- * @param parentIdMapper 鑾峰彇parentId鐨凢unction
- * @param idMapper 鑾峰彇id鐨凢unction
- * @param consumer 璧嬪�糲hildren鐨凜onsumer
- * @param <T> 鏁版嵁鐨勭被鍨�
- * @param <R> parentId鐨勭被鍨�
- * @return List<T>
- */
- public static <T, R> List<T> toTreeData(List<T> data,
- R parentId,
- Function<? super T, ? extends R> parentIdMapper,
- Function<? super T, ? extends R> idMapper,
- BiConsumer<T, List<T>> consumer) {
- List<T> result = new ArrayList<>();
- for (T d : data) {
- R dParentId = parentIdMapper.apply(d);
- if (parentId.equals(dParentId)) {
- R dId = idMapper.apply(d);
- List<T> children = toTreeData(data, dId, parentIdMapper, idMapper, consumer);
- if(children.size() > 0) {
- consumer.accept(d, children);
- }
- result.add(d);
- }
- }
- return result;
- }
-
-// public static <T> List<T> treeRemove(List<T> data, String condition,
-// Function<? super T, ? extends String> fetcher,
-// Function<T, List<T>> childrenGetter,
-// BiConsumer<T, List<T>> childrenSetter) {
-// List<T> result = new ArrayList<>();
-// for (T node : data) {
-// List<T> children = childrenGetter.apply(node);
-//
-// if (children != null && !children.isEmpty()) {
-// List<T> newChildren = treeRemove(children, condition, fetcher, childrenGetter, childrenSetter);
-// childrenSetter.accept(node, newChildren);
-// }
-//
-// if (fetcher.apply(node).contains(condition)) {
-// result.add(node);
-// }
-// }
-// return result;
-// }
-
- public static <T> void treeRemove(List<T> list, String condition, Function<? super T, ? extends String> fetcher, Function<T, List<T>> childrenGetter) {
- Iterator<T> iterator = list.iterator();
- while (iterator.hasNext()) {
- T next = iterator.next();
- List<T> children = childrenGetter.apply(next);
- if (children != null && !children.isEmpty()) {
- treeRemove(children, condition, fetcher, childrenGetter);
- } else {
- if (!fetcher.apply(next).contains(condition)) {
- iterator.remove();
- }
- }
- }
- }
-
- /**
- * 鏁扮粍鍊掑簭
- * @param bytes
- * @param <T>
- */
- public static <T> byte[] reverse(byte[] bytes) {
- if (bytes == null) return null;
- for (int start = 0, end = bytes.length - 1; start < end; start++, end--) {
- byte temp = bytes[end];
- bytes[end] = bytes[start];
- bytes[start] = temp;
- }
- return bytes;
- }
-
- /**
- * 鎴彇鏁扮粍
- * @param bytes 鍘熸暟缁�
- * @param pos 瀹氫綅锛堟埅鍙栧悗鍖呭惈瀹氫綅鐐规暟鎹級
- * @param len 闀垮害
- * @return new arr
- */
- public static byte[] slice(byte[] bytes, int pos, int len) {
- if (bytes == null || bytes.length == 0 || len == 0) {
- return new byte[0];
- }
- if (pos + len > bytes.length) {
- throw new RuntimeException("com.zy.acs.common.utils ArrayIndexOutOfBoundsException\n" +
- "鍘熸暟缁� bytes 闀垮害涓� " + bytes.length + "锛屾埅鍙栭暱搴﹁秴杩囧師鏁扮粍锛�");
- }
- byte[] arr = new byte[len];
- System.arraycopy(bytes, pos, arr, 0, len);
- return arr;
- }
-
- public static byte[] sliceWithReverse(byte[] bytes, int pos, int len) {
- byte[] slice = slice(bytes, pos, len);
- reverse(slice);
- return slice;
- }
-
- public static byte[] merge(Object... objects) {
- int len = 0;
- for (Object object : objects) {
- if (object instanceof byte[]) {
- byte[] bytes = (byte[]) object;
- len += bytes.length;
- }
- if (object instanceof Byte) {
- len++;
- }
- }
- byte[] arr = new byte[len];
- int idx = 0;
- for (Object object : objects) {
- if (object instanceof byte[]) {
- byte[] bytes = (byte[]) object;
- System.arraycopy(bytes, 0, arr, idx, bytes.length);
- idx += bytes.length;
- }
- if (object instanceof Byte) {
- byte[] bytes = new byte[] {(Byte) object};
- System.arraycopy(bytes, 0, arr, idx, bytes.length);
- idx += bytes.length;
- }
- }
- return arr;
- }
-
- public static <T> String join(T[] array, String seq) {
- StringBuilder sb = new StringBuilder();
- if (array != null) {
- for (int i = 0; i < array.length; i++) {
- sb.append(array[i]);
- if (i < array.length - 1) {
- sb.append(seq);
- }
- }
- }
- return sb.toString();
- }
-
- public static String zeroFill(String msg, Integer len) {
- len = Optional.ofNullable(len).orElse(16);
- if (msg.length() == len){
- return msg;
- } else if (msg.length() > len){
- return msg.substring(0, 16);
- } else {
- StringBuilder msgBuilder = new StringBuilder(msg);
- for (int i = 0; i<len-msg.length(); i++){
- msgBuilder.insert(0,"0");
- }
- return msgBuilder.toString();
- }
- }
-
- public static String removePrefix(String str, String prefix) {
- if (!Cools.isEmpty(str) && !Cools.isEmpty(prefix)) {
- if (str.startsWith(prefix)) {
- return str.substring(prefix.length());
- } else {
- return str;
- }
- } else {
- return str;
- }
- }
-
- public static String removeSuffix(String str, String suffix) {
- if (!Cools.isEmpty(str) && !Cools.isEmpty(suffix)) {
- if (str.endsWith(suffix)) {
- return str.substring(0, str.indexOf(suffix));
- } else {
- return str;
- }
- } else {
- return str;
- }
- }
-
- /**
- * 澶ч┘宄� 杞� symbol灏忛┘宄�
- */
- public static String toSymbolCase(String str, char symbol) {
- if (str == null) {
- return null;
- } else {
- int length = str.length();
- StringBuilder sb = new StringBuilder();
-
- for(int i = 0; i < length; ++i) {
- char c = str.charAt(i);
- if (Character.isUpperCase(c)) {
- Character preChar = i > 0 ? str.charAt(i - 1) : null;
- Character nextChar = i < str.length() - 1 ? str.charAt(i + 1) : null;
- if (null != preChar) {
- if (symbol == preChar) {
- if (null == nextChar || Character.isLowerCase(nextChar)) {
- c = Character.toLowerCase(c);
- }
- } else if (Character.isLowerCase(preChar)) {
- sb.append(symbol);
- if (null == nextChar || Character.isLowerCase(nextChar)) {
- c = Character.toLowerCase(c);
- }
- } else if (null == nextChar || Character.isLowerCase(nextChar)) {
- sb.append(symbol);
- c = Character.toLowerCase(c);
- }
- } else if (null == nextChar || Character.isLowerCase(nextChar)) {
- c = Character.toLowerCase(c);
- }
- }
-
- sb.append(c);
- }
-
- return sb.toString();
- }
- }
-
- public static String toCamelCase(CharSequence name) {
- if (null == name) {
- return null;
- } else {
- String name2 = name.toString();
- if (name2.contains("_")) {
- int length = name2.length();
- StringBuilder sb = new StringBuilder(length);
- boolean upperCase = false;
-
- for(int i = 0; i < length; ++i) {
- char c = name2.charAt(i);
- if (c == '_') {
- upperCase = true;
- } else if (upperCase) {
- sb.append(Character.toUpperCase(c));
- upperCase = false;
- } else {
- sb.append(Character.toLowerCase(c));
- }
- }
-
- return sb.toString();
- } else {
- return name2;
- }
- }
- }
-
- public static String sub(String str, Integer maxLen) {
- if (str.length() > maxLen) {
- return str.substring(0, maxLen);
- }
- return str;
- }
-
- public static String generateSeqNum(String lastSeqNum) {
- if (Cools.isEmpty(lastSeqNum)) {
- return zeroFill("1", 4);
- } else {
- int i = Integer.parseInt(lastSeqNum);
- if (i >= 9999) {
- return zeroFill("1", 4);
- } else {
- return zeroFill(String.valueOf(i+1), 4);
- }
- }
- }
-
- public static void cors(HttpServletResponse response){
- // 璺ㄥ煙璁剧疆
- response.setHeader("Access-Control-Max-Age", "3600");
- response.setHeader("Access-Control-Allow-Origin", "*");
- response.setHeader("Access-Control-Allow-Methods", "*");
- response.setHeader("Access-Control-Allow-Headers", "*");
- response.setHeader("Access-Control-Expose-Headers", Constants.TOKEN_HEADER_NAME);
- }
-
-}
+package com.zy.asrs.wms.utils;
+
+
+import com.alibaba.fastjson.JSON;
+import com.zy.asrs.framework.common.Cools;
+import com.zy.asrs.wms.asrs.entity.dto.MatUniqueObjDto;
+import com.zy.asrs.wms.asrs.entity.param.FieldParam;
+import com.zy.asrs.wms.common.constant.Constants;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.*;
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+
+/**
+ * Created by vincent on 2023/3/14
+ */
+public class Utils {
+
+ public static final String _LINK = "-";
+
+ public static String getMatUniqueKey(String matnr, String batch, List<FieldParam> params) {
+ MatUniqueObjDto dto = new MatUniqueObjDto();
+ dto.setMatnr(matnr);
+ dto.setBatch(batch);
+
+ ArrayList<FieldParam> list = new ArrayList<>();
+ for (FieldParam param : params) {
+ FieldParam fieldParam = new FieldParam();
+ list.add(fieldParam);
+
+ String value = "";
+ if (!Cools.isEmpty(param.getValue())) {
+ value = param.getValue().toString();
+ }
+
+ fieldParam.setName(param.getName());
+ fieldParam.setType(param.getType());
+ fieldParam.setValue(value);
+ }
+ dto.setParams(list);
+ String encode = Base64.getEncoder().encodeToString(JSON.toJSONString(dto).getBytes());
+ return encode;
+ }
+
+ public static MatUniqueObjDto getMatUniqueObj(String matUniqueKey) {
+ byte[] decode = Base64.getDecoder().decode(matUniqueKey);
+ String decodeStr = new String(decode);
+ MatUniqueObjDto dto = JSON.parseObject(decodeStr, MatUniqueObjDto.class);
+ return dto;
+ }
+
+ public static boolean checkMatSame(String matnr1, String batch1, List<FieldParam> params1, String matnr2, String batch2, List<FieldParam> params2) {
+ if (!matnr1.equals(matnr2)) {
+ return false;
+ }
+
+ if (batch1 != null && batch2 != null) {
+ if(!batch1.equals(batch2)) {
+ return false;
+ }
+ }
+
+ boolean check = true;
+ if(params1 != null && params2 != null) {
+ if(params1.size() != params2.size()) {
+ return false;
+ }
+
+ for (int i = 0; i < params1.size(); i++) {
+ FieldParam param1 = params1.get(i);
+ FieldParam param2 = params2.get(i);
+
+ if (!param1.getName().equals(param2.getName())) {
+ check = false;
+ break;
+ }
+
+ if(Cools.isEmpty(param1.getValue()) && Cools.isEmpty(param2.getValue())) {
+ continue;
+ }
+
+ if(!param1.getValue().equals(param2.getValue())) {
+ check = false;
+ break;
+ }
+ }
+
+ }
+
+ return check;
+ }
+
+ /**
+ * 閫氳繃搴撲綅鍙疯幏鍙� 鎺�
+ */
+ public static int getRow(String locNo) {
+ if (!Cools.isEmpty(locNo)) {
+ String[] split = locNo.split(_LINK);
+ return Integer.parseInt(split[0]);
+ }
+ throw new RuntimeException("搴撲綅瑙f瀽寮傚父");
+ }
+
+ /**
+ * 閫氳繃搴撲綅鍙疯幏鍙� 鍒�
+ */
+ public static int getBay(String locNo) {
+ if (!Cools.isEmpty(locNo)) {
+ String[] split = locNo.split(_LINK);
+ return Integer.parseInt(split[1]);
+ }
+ throw new RuntimeException("搴撲綅瑙f瀽寮傚父");
+ }
+
+ /**
+ * 閫氳繃搴撲綅鍙疯幏鍙� 灞�
+ */
+ public static int getLev(String locNo) {
+ if (!Cools.isEmpty(locNo)) {
+ String[] split = locNo.split(_LINK);
+ return Integer.parseInt(split[2]);
+ }
+ throw new RuntimeException("搴撲綅瑙f瀽寮傚父");
+ }
+
+ public static String getPlatLocNo(Number row, Number bay, Number lev) {
+ return "C" + zerofill(String.valueOf(row), 2) + "-" + zerofill(String.valueOf(bay), 2) + "-" + zerofill(String.valueOf(lev), 2);
+ }
+
+ public static String getLocNo(Number row, Number bay, Number lev) {
+ return row + _LINK + bay + _LINK + lev;
+ }
+
+ public static String zerofill(String msg, Integer count){
+ if (msg.length() == count){
+ return msg;
+ } else if (msg.length() > count){
+ return msg.substring(0, 16);
+ } else {
+ StringBuilder msgBuilder = new StringBuilder(msg);
+ for (int i = 0; i<count-msg.length(); i++){
+ msgBuilder.insert(0,"0");
+ }
+ return msgBuilder.toString();
+ }
+ }
+
+ /**
+ * List杞负鏍戝舰缁撴瀯
+ *
+ * @param data List
+ * @param parentId 椤剁骇鐨刾arentId
+ * @param parentIdMapper 鑾峰彇parentId鐨凢unction
+ * @param idMapper 鑾峰彇id鐨凢unction
+ * @param consumer 璧嬪�糲hildren鐨凜onsumer
+ * @param <T> 鏁版嵁鐨勭被鍨�
+ * @param <R> parentId鐨勭被鍨�
+ * @return List<T>
+ */
+ public static <T, R> List<T> toTreeData(List<T> data,
+ R parentId,
+ Function<? super T, ? extends R> parentIdMapper,
+ Function<? super T, ? extends R> idMapper,
+ BiConsumer<T, List<T>> consumer) {
+ List<T> result = new ArrayList<>();
+ for (T d : data) {
+ R dParentId = parentIdMapper.apply(d);
+ if (parentId.equals(dParentId)) {
+ R dId = idMapper.apply(d);
+ List<T> children = toTreeData(data, dId, parentIdMapper, idMapper, consumer);
+ if(children.size() > 0) {
+ consumer.accept(d, children);
+ }
+ result.add(d);
+ }
+ }
+ return result;
+ }
+
+// public static <T> List<T> treeRemove(List<T> data, String condition,
+// Function<? super T, ? extends String> fetcher,
+// Function<T, List<T>> childrenGetter,
+// BiConsumer<T, List<T>> childrenSetter) {
+// List<T> result = new ArrayList<>();
+// for (T node : data) {
+// List<T> children = childrenGetter.apply(node);
+//
+// if (children != null && !children.isEmpty()) {
+// List<T> newChildren = treeRemove(children, condition, fetcher, childrenGetter, childrenSetter);
+// childrenSetter.accept(node, newChildren);
+// }
+//
+// if (fetcher.apply(node).contains(condition)) {
+// result.add(node);
+// }
+// }
+// return result;
+// }
+
+ public static <T> void treeRemove(List<T> list, String condition, Function<? super T, ? extends String> fetcher, Function<T, List<T>> childrenGetter) {
+ Iterator<T> iterator = list.iterator();
+ while (iterator.hasNext()) {
+ T next = iterator.next();
+ List<T> children = childrenGetter.apply(next);
+ if (children != null && !children.isEmpty()) {
+ treeRemove(children, condition, fetcher, childrenGetter);
+ } else {
+ if (!fetcher.apply(next).contains(condition)) {
+ iterator.remove();
+ }
+ }
+ }
+ }
+
+ /**
+ * 鏁扮粍鍊掑簭
+ * @param bytes
+ * @param <T>
+ */
+ public static <T> byte[] reverse(byte[] bytes) {
+ if (bytes == null) return null;
+ for (int start = 0, end = bytes.length - 1; start < end; start++, end--) {
+ byte temp = bytes[end];
+ bytes[end] = bytes[start];
+ bytes[start] = temp;
+ }
+ return bytes;
+ }
+
+ /**
+ * 鎴彇鏁扮粍
+ * @param bytes 鍘熸暟缁�
+ * @param pos 瀹氫綅锛堟埅鍙栧悗鍖呭惈瀹氫綅鐐规暟鎹級
+ * @param len 闀垮害
+ * @return new arr
+ */
+ public static byte[] slice(byte[] bytes, int pos, int len) {
+ if (bytes == null || bytes.length == 0 || len == 0) {
+ return new byte[0];
+ }
+ if (pos + len > bytes.length) {
+ throw new RuntimeException("com.zy.acs.common.utils ArrayIndexOutOfBoundsException\n" +
+ "鍘熸暟缁� bytes 闀垮害涓� " + bytes.length + "锛屾埅鍙栭暱搴﹁秴杩囧師鏁扮粍锛�");
+ }
+ byte[] arr = new byte[len];
+ System.arraycopy(bytes, pos, arr, 0, len);
+ return arr;
+ }
+
+ public static byte[] sliceWithReverse(byte[] bytes, int pos, int len) {
+ byte[] slice = slice(bytes, pos, len);
+ reverse(slice);
+ return slice;
+ }
+
+ public static byte[] merge(Object... objects) {
+ int len = 0;
+ for (Object object : objects) {
+ if (object instanceof byte[]) {
+ byte[] bytes = (byte[]) object;
+ len += bytes.length;
+ }
+ if (object instanceof Byte) {
+ len++;
+ }
+ }
+ byte[] arr = new byte[len];
+ int idx = 0;
+ for (Object object : objects) {
+ if (object instanceof byte[]) {
+ byte[] bytes = (byte[]) object;
+ System.arraycopy(bytes, 0, arr, idx, bytes.length);
+ idx += bytes.length;
+ }
+ if (object instanceof Byte) {
+ byte[] bytes = new byte[] {(Byte) object};
+ System.arraycopy(bytes, 0, arr, idx, bytes.length);
+ idx += bytes.length;
+ }
+ }
+ return arr;
+ }
+
+ public static <T> String join(T[] array, String seq) {
+ StringBuilder sb = new StringBuilder();
+ if (array != null) {
+ for (int i = 0; i < array.length; i++) {
+ sb.append(array[i]);
+ if (i < array.length - 1) {
+ sb.append(seq);
+ }
+ }
+ }
+ return sb.toString();
+ }
+
+ public static String zeroFill(String msg, Integer len) {
+ len = Optional.ofNullable(len).orElse(16);
+ if (msg.length() == len){
+ return msg;
+ } else if (msg.length() > len){
+ return msg.substring(0, 16);
+ } else {
+ StringBuilder msgBuilder = new StringBuilder(msg);
+ for (int i = 0; i<len-msg.length(); i++){
+ msgBuilder.insert(0,"0");
+ }
+ return msgBuilder.toString();
+ }
+ }
+
+ public static String removePrefix(String str, String prefix) {
+ if (!Cools.isEmpty(str) && !Cools.isEmpty(prefix)) {
+ if (str.startsWith(prefix)) {
+ return str.substring(prefix.length());
+ } else {
+ return str;
+ }
+ } else {
+ return str;
+ }
+ }
+
+ public static String removeSuffix(String str, String suffix) {
+ if (!Cools.isEmpty(str) && !Cools.isEmpty(suffix)) {
+ if (str.endsWith(suffix)) {
+ return str.substring(0, str.indexOf(suffix));
+ } else {
+ return str;
+ }
+ } else {
+ return str;
+ }
+ }
+
+ /**
+ * 澶ч┘宄� 杞� symbol灏忛┘宄�
+ */
+ public static String toSymbolCase(String str, char symbol) {
+ if (str == null) {
+ return null;
+ } else {
+ int length = str.length();
+ StringBuilder sb = new StringBuilder();
+
+ for(int i = 0; i < length; ++i) {
+ char c = str.charAt(i);
+ if (Character.isUpperCase(c)) {
+ Character preChar = i > 0 ? str.charAt(i - 1) : null;
+ Character nextChar = i < str.length() - 1 ? str.charAt(i + 1) : null;
+ if (null != preChar) {
+ if (symbol == preChar) {
+ if (null == nextChar || Character.isLowerCase(nextChar)) {
+ c = Character.toLowerCase(c);
+ }
+ } else if (Character.isLowerCase(preChar)) {
+ sb.append(symbol);
+ if (null == nextChar || Character.isLowerCase(nextChar)) {
+ c = Character.toLowerCase(c);
+ }
+ } else if (null == nextChar || Character.isLowerCase(nextChar)) {
+ sb.append(symbol);
+ c = Character.toLowerCase(c);
+ }
+ } else if (null == nextChar || Character.isLowerCase(nextChar)) {
+ c = Character.toLowerCase(c);
+ }
+ }
+
+ sb.append(c);
+ }
+
+ return "`" + sb.toString() + "`";
+ }
+ }
+
+ public static String toCamelCase(CharSequence name) {
+ if (null == name) {
+ return null;
+ } else {
+ String name2 = name.toString();
+ if (name2.contains("_")) {
+ int length = name2.length();
+ StringBuilder sb = new StringBuilder(length);
+ boolean upperCase = false;
+
+ for(int i = 0; i < length; ++i) {
+ char c = name2.charAt(i);
+ if (c == '_') {
+ upperCase = true;
+ } else if (upperCase) {
+ sb.append(Character.toUpperCase(c));
+ upperCase = false;
+ } else {
+ sb.append(Character.toLowerCase(c));
+ }
+ }
+
+ return sb.toString();
+ } else {
+ return name2;
+ }
+ }
+ }
+
+ public static String sub(String str, Integer maxLen) {
+ if (str.length() > maxLen) {
+ return str.substring(0, maxLen);
+ }
+ return str;
+ }
+
+ public static String generateSeqNum(String lastSeqNum) {
+ if (Cools.isEmpty(lastSeqNum)) {
+ return zeroFill("1", 4);
+ } else {
+ int i = Integer.parseInt(lastSeqNum);
+ if (i >= 9999) {
+ return zeroFill("1", 4);
+ } else {
+ return zeroFill(String.valueOf(i+1), 4);
+ }
+ }
+ }
+
+ public static void cors(HttpServletResponse response){
+ // 璺ㄥ煙璁剧疆
+ response.setHeader("Access-Control-Max-Age", "3600");
+ response.setHeader("Access-Control-Allow-Origin", "*");
+ response.setHeader("Access-Control-Allow-Methods", "*");
+ response.setHeader("Access-Control-Allow-Headers", "*");
+ response.setHeader("Access-Control-Expose-Headers", Constants.TOKEN_HEADER_NAME);
+ }
+
+}
--
Gitblit v1.9.1