| | |
| | | import com.fzzy.api.Constant; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.apache.commons.lang.time.DateUtils; |
| | | import org.apache.commons.lang3.time.DateFormatUtils; |
| | | |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.UUID; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | public class ContextUtil { |
| | | |
| | | |
| | | /** |
| | | * 全局命令ID |
| | | */ |
| | | public static Map<String, Integer> contextOrderId = new HashMap<>(); |
| | | |
| | | |
| | | public static String getUUID() { |
| | |
| | | public static String getServerKey(String ip, Integer port) { |
| | | return ip + ":" + port; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据参数生成 执行命令的缓存KEY |
| | | * |
| | | * @param companyId |
| | | * @param serId |
| | | * @param bizType |
| | | * @return |
| | | */ |
| | | public static final String buildExeOrderId(String companyId, String serId, String bizType) { |
| | | Integer start = contextOrderId.get("ORDER_ID") == null ? 5000 : contextOrderId.get("ORDER_ID"); |
| | | |
| | | contextOrderId.put("ORDER_ID", start + 1); |
| | | |
| | | return start + ""; |
| | | } |
| | | |
| | | /** |
| | | * 设备ID生成规则 |
| | | * |
| | | * @param companyId |
| | | * @param depotId |
| | | * @param passCode |
| | | * @return |
| | | */ |
| | | public static final String buildDeviceId(String companyId, String depotId, int passCode) { |
| | | return companyId + "_" + depotId + "_" + passCode; |
| | | } |
| | | |
| | | public static String buildDeviceStatusKey(String companyId, String serId, String passCode) { |
| | | if (null == passCode) passCode = "NULL"; |
| | | return companyId + "_" + serId + "_STATUS_" + passCode; |
| | | } |
| | | |
| | | public static String buildDeviceStatusKey(String companyId, String serId, int passCode) { |
| | | return companyId + "_" + serId + "_STATUS_" + passCode; |
| | | } |
| | | |
| | | |
| | | public static String getDefaultBatchId() { |
| | | return DateFormatUtils.format(new Date(), "yyyyMMddHHmm"); |
| | | } |
| | | } |