Commit 6a5ea286 authored by tianchao's avatar tianchao

init

parent 993026be
**模块介绍**
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>platform</artifactId>
<groupId>pps</groupId>
<version>1.0.0-pps</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>C00-common</artifactId>
<version>1.0.0-pps</version>
<packaging>pom</packaging>
<modules>
<module>pps-common</module>
</modules>
<repositories>
<repository>
<id>central</id>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/repository/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>xstartup-hz</id>
<url>http://dev.sunboxauto.com/HZ/_packaging/xstartup-hz/maven/v1</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>xstartup-cloud</groupId>
<artifactId>xstartup-cloud-parent-core</artifactId>
<version>1.15.169-xstartup-cloud</version>
<relativePath/>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>pps</groupId>
<artifactId>pps-common</artifactId>
<version>1.0.0-pps</version>
<properties>
<maven.build.timestamp.format>yyyy.MMdd.HHmmss</maven.build.timestamp.format>
</properties>
<dependencies>
<dependency>
<groupId>huawei-gauss-db</groupId>
<artifactId>huawei-gauss-db</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.1-jre</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>xstartup</groupId>
<artifactId>xstartup-toolkit-office</artifactId>
</dependency>
<!--POI start-->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>4.1.2</version>
<scope>compile</scope>
</dependency>
<!--POI end-->
<!--jxls start-->
<dependency>
<groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
<version>0.4</version>
</dependency>
<dependency>
<groupId>org.jxls</groupId>
<artifactId>jxls</artifactId>
<version>2.4.6</version>
</dependency>
<dependency>
<groupId>org.jxls</groupId>
<artifactId>jxls-poi</artifactId>
<version>1.0.15</version>
</dependency>
<!--jxls end-->
<!--poiExcel-->
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-base</artifactId>
<version>3.2.0</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.10</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.itextpdf.tool</groupId>
<artifactId>xmlworker</artifactId>
<version>5.4.1</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.12</version>
</dependency>
<dependency>
<groupId>gui.ava</groupId>
<artifactId>html2image</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>core-renderer</artifactId>
<version>R8</version>
</dependency>
<dependency>
<groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId>
<version>2.5.0</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>commons-codec</groupId>-->
<!-- <artifactId>commons-codec</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.23.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>4.2.3</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>joor-java-8</artifactId>
<version>0.9.14</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- 打包jar文件时,配置manifest文件,加入lib包的jar依赖 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.2</version>
<configuration combine.self="override">
<archive>
<manifestEntries>
<Component-Group-Name>${project.groupId}</Component-Group-Name>
<Component-Artifactid>${project.artifactId}</Component-Artifactid>
<Component-Version>${project.version}</Component-Version>
<Component-Build-Time>${maven.build.timestamp}</Component-Build-Time>
<Component-Description>${project.description}</Component-Description>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>central</id>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/repository/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>xstartup-hz</id>
<url>http://dev.sunboxauto.com/HZ/_packaging/xstartup-hz/maven/v1</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</project>
package com.fasterxml.uuid;
import com.fasterxml.uuid.impl.TimeBasedEpochGenerator;
public class MyGenerator {
public static void main(String[] args){
TimeBasedEpochGenerator timeBasedEpochGenerator = Generators.timeBasedEpochGenerator();
int i=10;
while( i> 0){
String uuid = timeBasedEpochGenerator.generate().toString();
System.out.println(uuid);
i--;
}
}
}
package com.fasterxml.uuid;
import java.util.UUID;
/**
* Intermediate base class for UUID generators that do not take arguments for individual
* calls. This includes random and time-based variants, but not name-based ones.
*
* @since 3.0
*/
public abstract class NoArgGenerator extends UUIDGenerator
{
public abstract UUID generate();
}
package com.fasterxml.uuid;
import java.util.UUID;
/**
* Intermediate base class for UUID generators that take one String argument for individual
* calls. This includes name-based generators, but not random and time-based generators.
*
* @since 3.0
*/
public abstract class StringArgGenerator extends UUIDGenerator
{
/**
* Method for generating name-based UUIDs using specified name (serialized to
* bytes using UTF-8 encoding)
*/
public abstract UUID generate(String name);
/**
* Method for generating name-based UUIDs using specified byte-serialization
* of name.
*
* @since 3.1
*/
public abstract UUID generate(byte[] nameBytes);
}
/* JUG Java Uuid Generator
*
* Copyright (c) 2002- Tatu Saloranta, tatu.saloranta@iki.fi
*
* Licensed under the License specified in the file LICENSE which is
* included with the source code.
* You may not use this file except in compliance with the License.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.fasterxml.uuid;
import java.io.IOException;
/**
* This is the API for utility classes optionally used by {@link UUIDTimer} to
* ensure that timestamp values used for generating time/location-based UUIDs
* are monotonically increasing, as well as that only one such generator
* is ever used on a single system, even in presence of multiple JVMs.
*<p>
* The default implementation used by JUG is
* {@link com.fasterxml.uuid.ext.FileBasedTimestampSynchronizer}.
*/
public abstract class TimestampSynchronizer
{
protected TimestampSynchronizer() { }
/**
* Initialization method is will be called on an instance by
* {@link UUIDTimer} right after it's been configured with one.
* At this point the implementation instance should have been properly
* configured, and should be able to determine the first legal timestamp
* value (return value). Method should also initialize any locking that
* it does (if any), such as locking files it needs.
*<p>
* Return value thus indicates the lowest initial time value that can
* be used by the caller that can not have been used by previous
* incarnations of the UUID generator (assuming instance was able to
* find properly persisted data to figure that out).
* However, caller also needs to make sure that it will
* call {@link #update} when it actually needs the time stamp for the
* first time,
* since this method can not allocate timestamps beyond this initial
* value at this point.
*
* @return First (and last) legal timestamp to use; <code>0L</code> if it
* can not
* determine it and caller can use whatever value (current timestamp)
* it has access to.
*/
protected abstract long initialize()
throws IOException;
/**
* Method {@link UUIDTimer} will call if this synchronizer object is
* being replaced by another synchronizer (or removed, that is, no
* more synchronization is to be done). It will not be called if JVM
* terminates.
*/
protected abstract void deactivate()
throws IOException;
/**
* Method called by {@link UUIDTimer} to indicate that it has generated
* a timestamp value that is beyond last legal timestamp value.
* The method should only return once it has "locked" specified timestamp
* value (and possible additional ones).
*
* @param now Timestamp value caller wants to use, and that the
* synchronizer is asked to protect.
*
* @return First timestamp value that can NOT be used by the caller;
* has to be higher than the input timestamp value
*/
protected abstract long update(long now)
throws IOException;
}
/* JUG Java Uuid Generator
*
* Copyright (c) 2002 Tatu Saloranta, tatu.saloranta@iki.fi
*
* Licensed under the License specified in the file LICENSE which is
* included with the source code.
* You may not use this file except in compliance with the License.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.fasterxml.uuid;
/**
* UUIDClock is used by UUIDTimer to get the current time. The default
* implementation returns the time from the system clock, but this class can
* be overriden to return any number. This is useful when UUIDs with past or
* future timestamps should be generated, or when UUIDs must be generated in
* a reproducible manner.
*
* @since 3.3
*/
public class UUIDClock
{
/**
* Returns the current time in milliseconds.
*/
public long currentTimeMillis()
{
return System.currentTimeMillis();
}
}
package com.fasterxml.uuid;
import java.util.Comparator;
import java.util.UUID;
/**
* Default {@link java.util.UUID} comparator is not very useful, since
* it just does blind byte-by-byte comparison which does not work well
* for time+location - based UUIDs. Additionally it also uses signed
* comparisons for longs which can lead to unexpected behavior
* This comparator does implement proper lexical ordering: starting with
* type (different types are collated
* separately), followed by time and location (for time/location based),
* and simple lexical (byte-by-byte) ordering for name/hash and random
* variants.
*
* @author tatu
*/
public class UUIDComparator implements Comparator<UUID>
{
@Override
public int compare(UUID u1, UUID u2)
{
return staticCompare(u1, u2);
}
/**
* Static helper method that can be used instead of instantiating comparator
* (used by unit tests, can be used by code too)
*/
public static int staticCompare(UUID u1, UUID u2)
{
// First: major sorting by types
int type = u1.version();
int diff = type - u2.version();
if (diff != 0) {
return diff;
}
// Second: for time-based variant, order by time stamp:
if (type == UUIDType.TIME_BASED.raw()) {
diff = compareULongs(u1.timestamp(), u2.timestamp());
if (diff == 0) {
// or if that won't work, by other bits lexically
diff = compareULongs(u1.getLeastSignificantBits(), u2.getLeastSignificantBits());
}
} else {
// note: java.util.UUIDs compares with sign extension, IMO that's wrong, so:
diff = compareULongs(u1.getMostSignificantBits(),
u2.getMostSignificantBits());
if (diff == 0) {
diff = compareULongs(u1.getLeastSignificantBits(),
u2.getLeastSignificantBits());
}
}
return diff;
}
protected final static int compareULongs(long l1, long l2) {
int diff = compareUInts((int) (l1 >> 32), (int) (l2 >> 32));
if (diff == 0) {
diff = compareUInts((int) l1, (int) l2);
}
return diff;
}
protected final static int compareUInts(int i1, int i2)
{
/* bit messier due to java's insistence on signed values: if both
* have same sign, normal comparison (by subtraction) works fine;
* but if signs don't agree need to resolve differently
*/
if (i1 < 0) {
return (i2 < 0) ? (i1 - i2) : 1;
}
return (i2 < 0) ? -1 : (i1 - i2);
}
}
/* JUG Java UUID Generator
*
* Copyright (c) 2002- Tatu Saloranta, tatu.saloranta@iki.fi
*
* Licensed under the License specified in the file LICENSE which is
* included with the source code.
* You may not use this file except in compliance with the License.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.fasterxml.uuid;
/**
* Minimal "tag" base class from which all generator implementations
* derive. Actual generation methods are not included since different
* generators take different number of arguments.
*
* @since 3.0
*/
public abstract class UUIDGenerator
{
/*
/**********************************************************
/* Life-cycle
/**********************************************************
*/
/**
* Constructor is private to enforce singleton access.
*/
protected UUIDGenerator() { }
/*
/**********************************************************
/* Shared (minimal) API
/**********************************************************
*/
/**
* Accessor for determining type of UUIDs (variant) that this
* generator instance will produce.
*/
public abstract UUIDType getType();
}
package com.fasterxml.uuid;
/**
* Enumeration of different flavors of UUIDs: 5 specified by specs
* (<a href="http://tools.ietf.org/html/rfc4122">RFC-4122</a>)
* and one
* virtual entry ("UNKNOWN") to represent invalid one that consists of
* all zero bites
*/
public enum UUIDType {
TIME_BASED(1),
DCE(2),
NAME_BASED_MD5(3),
RANDOM_BASED(4),
NAME_BASED_SHA1(5),
TIME_BASED_REORDERED(6),
TIME_BASED_EPOCH(7),
FREE_FORM(8),
UNKNOWN(0);
private final int _raw;
private UUIDType(int raw) {
_raw = raw;
}
/**
* Returns "raw" type constants, embedded within UUID bytes.
*/
public int raw() { return _raw; }
}
/* JUG Java Uuid Generator
*
* Copyright (c) 2002- Tatu Saloranta, tatu.saloranta@iki.fi
*
* Licensed under the License specified in the file LICENSE which is
* included with the source code.
* You may not use this file except in compliance with the License.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.fasterxml.uuid.ext;
import com.fasterxml.uuid.TimestampSynchronizer;
import java.io.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Implementation of {@link TimestampSynchronizer}, which uses file system
* as the storage and locking mechanism.
*<p>
* Synchronization is achieved by obtaining an exclusive file locks on two
* specified lock files, and by using the files to store first "safe" timestamp
* value that the generator can use; alternating between one to use to ensure
* one of them always contains a valid timestamp. Latter is needed to guard
* against system clock moving backwards after UUID generator restart.
*<p>
* Note: this class will only work on JDK 1.4 and above, since it requires
* NIO package to do proper file locking (as well as new opening mode for
* {@link RandomAccessFile}).
*<p>
* Also note that it is assumed that the caller has taken care to synchronize
* access to method to be single-threaded. As such, none of the methods
* is explicitly synchronized here.
*/
public final class FileBasedTimestampSynchronizer
extends TimestampSynchronizer
{
private static final Logger logger = LoggerFactory.getLogger(FileBasedTimestampSynchronizer.class);
// // // Constants:
/**
* The default update interval is 10 seconds, meaning that the
* synchronizer "reserves" next 10 seconds for generation. This
* also means that the lock files need to be accessed at most
* once every ten second.
*/
final static long DEFAULT_UPDATE_INTERVAL = 10L * 1000L;
protected final static String DEFAULT_LOCK_FILE_NAME1 = "uuid1.lck";
protected final static String DEFAULT_LOCK_FILE_NAME2 = "uuid2.lck";
// // // Configuration:
protected long mInterval = DEFAULT_UPDATE_INTERVAL;
protected final LockedFile mLocked1, mLocked2;
// // // State:
/**
* Flag used to indicate which of timestamp files has the most
* recently succesfully updated timestamp value. True means that
* <code>mFile1</code> is more recent; false that <code>mFile2</code>
* is.
*/
boolean mFirstActive = false;
/**
* Constructor that uses default values for names of files to use
* (files will get created in the current working directory), as
* well as for the update frequency value (10 seconds).
*/
public FileBasedTimestampSynchronizer()
throws IOException
{
this(new File(DEFAULT_LOCK_FILE_NAME1), new File(DEFAULT_LOCK_FILE_NAME2));
}
public FileBasedTimestampSynchronizer(File lockFile1, File lockFile2)
throws IOException
{
this(lockFile1, lockFile2, DEFAULT_UPDATE_INTERVAL);
}
public FileBasedTimestampSynchronizer(File lockFile1, File lockFile2, long interval)
throws IOException
{
mInterval = interval;
mLocked1 = new LockedFile(lockFile1);
boolean ok = false;
try {
mLocked2 = new LockedFile(lockFile2);
ok = true;
} finally {
if (!ok) {
mLocked1.deactivate();
}
}
// But let's leave reading up to initialization
}
/*
//////////////////////////////////////////////////////////////
// Configuration
//////////////////////////////////////////////////////////////
*/
public void setUpdateInterval(long interval)
{
if (interval < 1L) {
throw new IllegalArgumentException("Illegal value ("+interval+"); has to be a positive integer value");
}
mInterval = interval;
}
/*
//////////////////////////////////////////////////////////////
// Implementation of the API
//////////////////////////////////////////////////////////////
*/
/**
* This method is to be called only once by
* {@link com.fasterxml.uuid.UUIDTimer}. It
* should fetch the persisted timestamp value, which indicates
* first timestamp value that is guaranteed NOT to have used by
* a previous incarnation. If it can not determine such value, it
* is to return 0L as a marker.
*
* @return First timestamp value that was NOT locked by lock files;
* 0L to indicate that no information was read.
*/
@Override
protected long initialize() throws IOException
{
long ts1 = mLocked1.readStamp();
long ts2 = mLocked2.readStamp();
long result;
if (ts1 > ts2) {
mFirstActive = true;
result = ts1;
} else {
mFirstActive = false;
result = ts2;
}
/* Hmmh. If we didn't get a time stamp (-> 0), or if written time is
* ahead of current time, let's log something:
*/
if (result <= 0L) {
logger.warn("Could not determine safe timer starting point: assuming current system time is acceptable");
} else {
long now = System.currentTimeMillis();
//long diff = now - result;
/* It's more suspicious if old time was ahead... although with
* longer iteration values, it can be ahead without errors. So
* let's base check on current iteration value:
*/
if ((now + mInterval) < result) {
logger.warn("Safe timestamp read is {} milliseconds in future, and is greater than the inteval ({})", (result - now), mInterval);
}
/* Hmmh. Is there any way a suspiciously old timestamp could be
* harmful? It can obviously be useless but...
*/
}
return result;
}
@Override
public void deactivate() throws IOException
{
doDeactivate(mLocked1, mLocked2);
}
/**
* @return Timestamp value that the caller can NOT use. That is, all
* timestamp values prior to (less than) this value can be used
* ok, but this value and ones after can only be used by first
* calling update.
*/
@Override
public long update(long now)
throws IOException
{
long nextAllowed = now + mInterval;
/* We have to make sure to (over)write the one that is NOT
* actively used, to ensure that we always have fully persisted
* timestamp value, even if the write process gets interruped
* half-way through.
*/
if (mFirstActive) {
mLocked2.writeStamp(nextAllowed);
} else {
mLocked1.writeStamp(nextAllowed);
}
mFirstActive = !mFirstActive;
return nextAllowed;
}
/*
//////////////////////////////////////////////////////////////
// Internal methods
//////////////////////////////////////////////////////////////
*/
protected static void doDeactivate(LockedFile lf1, LockedFile lf2)
{
if (lf1 != null) {
lf1.deactivate();
}
if (lf2 != null) {
lf2.deactivate();
}
}
}
/* JUG Java Uuid Generator
*
* Copyright (c) 2002- Tatu Saloranta, tatu.saloranta@iki.fi
*
* Licensed under the License specified in the file LICENSE which is
* included with the source code.
* You may not use this file except in compliance with the License.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.fasterxml.uuid.ext;
import java.io.*;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Utility class used by {@link FileBasedTimestampSynchronizer} to do
* actual file access and locking.
*<p>
* Class stores simple timestamp values based on system time accessed
* using <code>System.currentTimeMillis()</code>. A single timestamp
* is stored into a file using {@link RandomAccessFile} in fully
* synchronized mode. Value is written in ISO-Latin (ISO-8859-1)
* encoding (superset of Ascii, 1 byte per char) as 16-digit hexadecimal
* number, surrounded by brackets. As such, file produced should
* always have exact size of 18 bytes. For extra robustness, slight
* variations in number of digits are accepeted, as are white space
* chars before and after bracketed value.
*/
class LockedFile
{
private static final Logger logger = LoggerFactory.getLogger(LockedFile.class);
/**
* Expected file length comes from hex-timestamp (16 digits),
* preamble "[0x",(3 chars) and trailer "]\r\n" (2 chars, linefeed
* to help debugging -- in some environments, missing trailing linefeed
* causes problems: also, 2-char linefeed to be compatible with all
* standard linefeeds on MacOS, Unix and Windows).
*/
final static int DEFAULT_LENGTH = 22;
final static long READ_ERROR = 0L;
// // // Configuration:
final File mFile;
// // // File state
RandomAccessFile mRAFile;
FileChannel mChannel;
FileLock mLock;
ByteBuffer mWriteBuffer = null;
/**
* Flag set if the original file (created before this instance was
* created) had size other than default size and needs to be
* truncated
*/
boolean mWeirdSize;
/**
* Marker used to ensure that the timestamps stored are monotonously
* increasing. Shouldn't really be needed, since caller should take
* care of it, but let's be bit paranoid here.
*/
long mLastTimestamp = 0L;
LockedFile(File f)
throws IOException
{
mFile = f;
RandomAccessFile raf = null;
FileChannel channel = null;
FileLock lock = null;
boolean ok = false;
try { // let's just use a single block to share cleanup code
raf = new RandomAccessFile(f, "rwd");
// Then lock them, if possible; if not, let's err out
channel = raf.getChannel();
if (channel == null) {
throw new IOException("Failed to access channel for '"+f+"'");
}
lock = channel.tryLock();
if (lock == null) {
throw new IOException("Failed to lock '"+f+"' (another JVM running UUIDGenerator?)");
}
ok = true;
} finally {
if (!ok) {
doDeactivate(f, raf, lock);
}
}
mRAFile = raf;
mChannel = channel;
mLock = lock;
}
public void deactivate()
{
RandomAccessFile raf = mRAFile;
mRAFile = null;
FileLock lock = mLock;
mLock = null;
doDeactivate(mFile, raf, lock);
}
public long readStamp()
{
int size;
try {
size = (int) mChannel.size();
} catch (IOException ioe) {
logger.error("Failed to read file size", ioe);
return READ_ERROR;
}
mWeirdSize = (size != DEFAULT_LENGTH);
// Let's check specifically empty files though
if (size == 0) {
logger.warn("Missing or empty file, can not read timestamp value");
return READ_ERROR;
}
// Let's also allow some slack... but just a bit
if (size > 100) {
size = 100;
}
byte[] data = new byte[size];
try {
mRAFile.readFully(data);
} catch (IOException ie) {
logger.error("(file '{}') Failed to read {} bytes", mFile, size, ie);
return READ_ERROR;
}
/* Ok, got data. Now, we could just directly parse the bytes (since
* it is single-byte encoding)... but for convenience, let's create
* the String (this is only called once per JVM session)
*/
char[] cdata = new char[size];
for (int i = 0; i < size; ++i) {
cdata[i] = (char) (data[i] & 0xFF);
}
String dataStr = new String(cdata);
// And let's trim leading (and trailing, who cares)
dataStr = dataStr.trim();
long result = -1;
String err = null;
if (!dataStr.startsWith("[0")
|| dataStr.length() < 3
|| Character.toLowerCase(dataStr.charAt(2)) != 'x') {
err = "does not start with '[0x' prefix";
} else {
int ix = dataStr.indexOf(']', 3);
if (ix <= 0) {
err = "does not end with ']' marker";
} else {
String hex = dataStr.substring(3, ix);
if (hex.length() > 16) {
err = "length of the (hex) timestamp too long; expected 16, had "+hex.length()+" ('"+hex+"')";
} else {
try {
result = Long.parseLong(hex, 16);
} catch (NumberFormatException nex) {
err = "does not contain a valid hex timestamp; got '"
+hex+"' (parse error: "+nex+")";
}
}
}
}
// Unsuccesful?
if (result < 0L) {
logger.error("(file '{}') Malformed timestamp file contents: {}", mFile, err);
return READ_ERROR;
}
mLastTimestamp = result;
return result;
}
final static String HEX_DIGITS = "0123456789abcdef";
public void writeStamp(long stamp)
throws IOException
{
// Let's do sanity check first:
if (stamp <= mLastTimestamp) {
/* same stamp is not dangerous, but pointless... so warning,
* not an error:
*/
if (stamp == mLastTimestamp) {
logger.warn("(file '{}') Trying to re-write existing timestamp ({})", mFile, stamp);
return;
}
throw new IOException(""+mFile+" trying to overwrite existing value ("+mLastTimestamp+") with an earlier timestamp ("+stamp+")");
}
//System.err.println("!!!! Syncing ["+mFile+"] with "+stamp+" !!!");
// Need to initialize the buffer?
if (mWriteBuffer == null) {
mWriteBuffer = ByteBuffer.allocate(DEFAULT_LENGTH);
mWriteBuffer.put(0, (byte) '[');
mWriteBuffer.put(1, (byte) '0');
mWriteBuffer.put(2, (byte) 'x');
mWriteBuffer.put(19, (byte) ']');
mWriteBuffer.put(20, (byte) '\r');
mWriteBuffer.put(21, (byte) '\n');
}
// Converting to hex is simple
for (int i = 18; i >= 3; --i) {
int val = (((int) stamp) & 0x0F);
mWriteBuffer.put(i, (byte) HEX_DIGITS.charAt(val));
stamp = (stamp >> 4);
}
// and off we go:
mWriteBuffer.position(0); // to make sure we always write it all
mChannel.write(mWriteBuffer, 0L);
if (mWeirdSize) {
mRAFile.setLength(DEFAULT_LENGTH);
mWeirdSize = false;
}
// This is probably not needed (as the random access file is supposedly synced)... but let's be safe:
mChannel.force(false);
// And that's it!
}
/*
//////////////////////////////////////////////////////////////
// Internal methods
//////////////////////////////////////////////////////////////
*/
protected static void doDeactivate(File f, RandomAccessFile raf,
FileLock lock)
{
if (lock != null) {
try {
lock.release();
} catch (Throwable t) {
logger.error("Failed to release lock (for file '{}')", f, t);
}
}
if (raf != null) {
try {
raf.close();
} catch (Throwable t) {
logger.error("Failed to close file '{}'", f, t);
}
}
}
}
/**
Package that contains optional Java UUID Generator classes; classes that:
<ul>
<li>Depend on optional external packages; like log4j or java.util.logging -
based Logger adapters
</li>
</ul>
*/
package com.fasterxml.uuid.ext;
package com.fasterxml.uuid.impl;
import java.security.SecureRandom;
/**
* Trivial helper class that uses class loading as synchronization
* mechanism for lazy instantiation of the shared secure random
* instance.
*/
public final class LazyRandom
{
private final static SecureRandom shared = new SecureRandom();
public static SecureRandom sharedSecureRandom() {
return shared;
}
}
\ No newline at end of file
package com.fasterxml.uuid.impl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Wrapper we (only) need to support CLI usage (see {@link com.fasterxml.uuid.Jug}
* wherein we do not actually have logger package included; in which case we
* will print warning(s) out to {@code System.err}.
* For normal embedded usage no benefits, except if someone forgot their SLF4j API
* package. :)
*
* @since 4.1
*/
public class LoggerFacade {
private final Class<?> _forClass;
private WrappedLogger _logger;
private LoggerFacade(Class<?> forClass) {
_forClass = forClass;
}
public static LoggerFacade getLogger(Class<?> forClass) {
return new LoggerFacade(forClass);
}
public void warn(String msg) {
_warn(msg);
}
public void warn(String msg, Object arg) {
_warn(String.format(msg, arg));
}
public void warn(String msg, Object arg, Object arg2) {
_warn(String.format(msg, arg, arg2));
}
private synchronized void _warn(String message) {
if (_logger == null) {
_logger = WrappedLogger.logger(_forClass);
}
_logger.warn(message);
}
private static class WrappedLogger {
private final Logger _logger;
private WrappedLogger(Logger l) {
_logger = l;
}
public static WrappedLogger logger(Class<?> forClass) {
// Why all these contortions? To support case where Slf4j API missing
// (or, if it ever fails for not having impl) to just print to STDERR
try {
return new WrappedLogger(LoggerFactory.getLogger(forClass));
} catch (Throwable t) {
return new WrappedLogger(null);
}
}
public void warn(String message) {
if (_logger != null) {
_logger.warn(message);
} else {
System.err.println("WARN: "+message);
}
}
}
}
package com.fasterxml.uuid.impl;
import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.util.UUID;
import com.fasterxml.uuid.StringArgGenerator;
import com.fasterxml.uuid.UUIDType;
/**
* Implementation of UUID generator that uses one of name-based generation methods
* (variants 3 (MD5) and 5 (SHA1)).
*<p>
* As all JUG provided implementations, this generator is fully thread-safe; access
* to digester is synchronized as necessary.
*
* @since 3.0
*/
public class NameBasedGenerator extends StringArgGenerator
{
public final static Charset _utf8;
static {
_utf8 = Charset.forName("UTF-8");
}
private final LoggerFacade _logger = LoggerFacade.getLogger(getClass());
/**
* Namespace used when name is a DNS name.
*/
public final static UUID NAMESPACE_DNS = UUID.fromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8");
/**
* Namespace used when name is a URL.
*/
public final static UUID NAMESPACE_URL = UUID.fromString("6ba7b811-9dad-11d1-80b4-00c04fd430c8");
/**
* Namespace used when name is an OID.
*/
public final static UUID NAMESPACE_OID = UUID.fromString("6ba7b812-9dad-11d1-80b4-00c04fd430c8");
/**
* Namespace used when name is an X500 identifier
*/
public final static UUID NAMESPACE_X500 = UUID.fromString("6ba7b814-9dad-11d1-80b4-00c04fd430c8");
/*
/**********************************************************************
/* Configuration
/**********************************************************************
*/
/**
* Namespace to use as prefix.
*/
protected final UUID _namespace;
/**
* Message digesster to use for hash calculation
*/
protected final MessageDigest _digester;
protected final UUIDType _type;
/*
/**********************************************************************
/* Construction
/**********************************************************************
*/
/**
* @param namespace of the namespace, as defined by the
* spec. UUID has 4 pre-defined "standard" name space strings
* that can be passed to UUID constructor (see example below).
* Note that this argument is optional; if no namespace is needed
* (for example when name includes namespace prefix), null may be passed.
* @param digester Hashing algorithm to use.
*/
public NameBasedGenerator(UUID namespace, MessageDigest digester, UUIDType type)
{
_namespace = namespace;
// And default digester SHA-1
if (digester == null) {
throw new IllegalArgumentException("Digester not optional: cannot pass `null`");
}
if (type == null) {
String typeStr = digester.getAlgorithm();
if (typeStr.startsWith("MD5")) {
type = UUIDType.NAME_BASED_MD5;
} else if (typeStr.startsWith("SHA")) {
type = UUIDType.NAME_BASED_SHA1;
} else {
// Hmmh... error out? Let's default to SHA-1, but log a warning
type = UUIDType.NAME_BASED_SHA1;
_logger.warn("Could not determine type of Digester from '%s'; assuming 'SHA-1' type", typeStr);
}
}
_digester = digester;
_type = type;
}
/*
/**********************************************************************
/* Access to config
/**********************************************************************
*/
@Override
public UUIDType getType() { return _type; }
public UUID getNamespace() { return _namespace; }
/*
/**********************************************************************
/* UUID generation
/**********************************************************************
*/
@Override
public UUID generate(String name)
{
// !!! TODO: 14-Oct-2010, tatu: can repurpose faster UTF-8 encoding from Jackson
return generate(name.getBytes(_utf8));
}
@Override
public UUID generate(byte[] nameBytes)
{
byte[] digest;
synchronized (_digester) {
_digester.reset();
if (_namespace != null) {
_digester.update(UUIDUtil.asByteArray(_namespace));
}
_digester.update(nameBytes);
digest = _digester.digest();
}
return UUIDUtil.constructUUID(_type, digest);
}
}
package com.fasterxml.uuid.impl;
import java.security.SecureRandom;
import java.util.Random;
import java.util.UUID;
import com.fasterxml.uuid.NoArgGenerator;
import com.fasterxml.uuid.UUIDType;
/**
* Implementation of UUID generator that uses generation method 4.
*<p>
* Note on random number generation when using {@link SecureRandom} for random number
* generation: the first time {@link SecureRandom} object is used, there is noticeable delay between
* calling the method and getting the reply. This is because SecureRandom
* has to initialize itself to reasonably random state. Thus, if you
* want to lessen delay, it may be be a good idea to either get the
* first random UUID asynchronously from a separate thread, or to
* use the other generateRandomBasedUUID passing a previously initialized
* SecureRandom instance.
*
* @since 3.0
*/
public class RandomBasedGenerator extends NoArgGenerator
{
/**
* Default shared random number generator, used if no random number generator
* is explicitly specified for instance
*/
protected static Random _sharedRandom = null;
/**
* Random number generator that this generator uses.
*/
protected final Random _random;
/**
* Looks like {@link SecureRandom} implementation is more efficient
* using single call access (compared to basic {@link java.util.Random}),
* so let's use that knowledge to our benefit.
*/
protected final boolean _secureRandom;
/**
* @param rnd Random number generator to use for generating UUIDs; if null,
* shared default generator is used. Note that it is strongly recommend to
* use a <b>good</b> (pseudo) random number generator; for example, JDK's
* {@link SecureRandom}.
*/
public RandomBasedGenerator(Random rnd)
{
if (rnd == null) {
rnd = LazyRandom.sharedSecureRandom();
_secureRandom = true;
} else {
_secureRandom = (rnd instanceof SecureRandom);
}
_random = rnd;
}
/*
/**********************************************************************
/* Access to config
/**********************************************************************
*/
@Override
public UUIDType getType() { return UUIDType.RANDOM_BASED; }
/*
/**********************************************************************
/* UUID generation
/**********************************************************************
*/
@Override
public UUID generate()
{
// 14-Oct-2010, tatu: Surprisingly, variant for reading byte array is
// tad faster for SecureRandom... so let's use that then
long r1, r2;
if (_secureRandom) {
final byte[] buffer = new byte[16];
_random.nextBytes(buffer);
r1 = _toLong(buffer, 0);
r2 = _toLong(buffer, 1);
} else {
r1 = _random.nextLong();
r2 = _random.nextLong();
}
return UUIDUtil.constructUUID(UUIDType.RANDOM_BASED, r1, r2);
}
/*
/**********************************************************************
/* Internal methods
/**********************************************************************
*/
protected final static long _toLong(byte[] buffer, int offset)
{
long l1 = _toInt(buffer, offset);
long l2 = _toInt(buffer, offset+4);
long l = (l1 << 32) + ((l2 << 32) >>> 32);
return l;
}
private final static long _toInt(byte[] buffer, int offset)
{
return (buffer[offset] << 24)
+ ((buffer[++offset] & 0xFF) << 16)
+ ((buffer[++offset] & 0xFF) << 8)
+ (buffer[++offset] & 0xFF);
}
}
package com.fasterxml.uuid.impl;
import java.security.SecureRandom;
import java.util.Random;
import java.util.UUID;
import com.fasterxml.uuid.NoArgGenerator;
import com.fasterxml.uuid.UUIDType;
/**
* Implementation of UUID generator that uses time/location based generation
* method field from the Unix Epoch timestamp source - the number of
* milliseconds seconds since midnight 1 Jan 1970 UTC, leap seconds excluded
* <p>
* As all JUG provided implementations, this generator is fully thread-safe.
* Additionally it can also be made externally synchronized with other instances
* (even ones running on other JVMs); to do this, use
* {@link com.fasterxml.uuid.ext.FileBasedTimestampSynchronizer} (or
* equivalent).
*
* @since 4.1
*/
public class TimeBasedEpochGenerator extends NoArgGenerator
{
/*
/**********************************************************************
/* Configuration
/**********************************************************************
*/
/**
* Random number generator that this generator uses.
*/
protected final Random _random;
/*
/**********************************************************************
/* Construction
/**********************************************************************
*/
/**
* @param rnd Random number generator to use for generating UUIDs; if null,
* shared default generator is used. Note that it is strongly recommend to
* use a <b>good</b> (pseudo) random number generator; for example, JDK's
* {@link SecureRandom}.
*/
public TimeBasedEpochGenerator(Random rnd)
{
if (rnd == null) {
rnd = LazyRandom.sharedSecureRandom();
}
_random = rnd;
}
/*
/**********************************************************************
/* Access to config
/**********************************************************************
*/
@Override
public UUIDType getType() { return UUIDType.TIME_BASED_EPOCH; }
/*
/**********************************************************************
/* UUID generation
/**********************************************************************
*/
@Override
public UUID generate()
{
final long rawTimestamp = System.currentTimeMillis();
final byte[] rnd = new byte[10];
_random.nextBytes(rnd);
// Use only 48 lowest bits as per spec, next 16 bit from random
// (note: UUIDUtil.constuctUUID will add "version" so it's only 12
// actual random bits)
long l1 = (rawTimestamp << 16) | _toShort(rnd, 8);
// And then the other 64 bits of random; likewise UUIDUtil.constructUUID
// will overwrite first 2 random bits so it's "only" 62 bits
long l2 = _toLong(rnd, 0);
// and as per above, this call fills in "variant" and "version" bits
return UUIDUtil.constructUUID(UUIDType.TIME_BASED_EPOCH, l1, l2);
}
/*
/**********************************************************************
/* Internal methods
/**********************************************************************
*/
protected final static long _toLong(byte[] buffer, int offset)
{
long l1 = _toInt(buffer, offset);
long l2 = _toInt(buffer, offset+4);
long l = (l1 << 32) + ((l2 << 32) >>> 32);
return l;
}
private final static long _toInt(byte[] buffer, int offset)
{
return (buffer[offset] << 24)
+ ((buffer[++offset] & 0xFF) << 16)
+ ((buffer[++offset] & 0xFF) << 8)
+ (buffer[++offset] & 0xFF);
}
private final static long _toShort(byte[] buffer, int offset)
{
return ((buffer[offset] & 0xFF) << 8)
+ (buffer[++offset] & 0xFF);
}
}
package com.fasterxml.uuid.impl;
import java.util.UUID;
import com.fasterxml.uuid.*;
/**
* Implementation of UUID generator that uses time/location based generation
* method (variant 1).
*<p>
* As all JUG provided implementations, this generator is fully thread-safe.
* Additionally it can also be made externally synchronized with other
* instances (even ones running on other JVMs); to do this,
* use {@link com.fasterxml.uuid.ext.FileBasedTimestampSynchronizer}
* (or equivalent).
*
* @since 3.0
*/
public class TimeBasedGenerator extends NoArgGenerator
{
/*
/**********************************************************************
/* Configuration
/**********************************************************************
*/
protected final EthernetAddress _ethernetAddress;
/**
* Object used for synchronizing access to timestamps, to guarantee
* that timestamps produced by this generator are unique and monotonically increasings.
* Some implementations offer even stronger guarantees, for example that
* same guarantee holds between instances running on different JVMs (or
* with native code).
*/
protected final UUIDTimer _timer;
/**
* Base values for the second long (last 8 bytes) of UUID to construct
*/
protected final long _uuidL2;
/*
/**********************************************************************
/* Construction
/**********************************************************************
*/
/**
* @param ethAddr Hardware address (802.1) to use for generating
* spatially unique part of UUID. If system has more than one NIC,
*/
public TimeBasedGenerator(EthernetAddress ethAddr, UUIDTimer timer)
{
byte[] uuidBytes = new byte[16];
if (ethAddr == null) {
ethAddr = EthernetAddress.constructMulticastAddress();
}
// initialize baseline with MAC address info
_ethernetAddress = ethAddr;
_ethernetAddress.toByteArray(uuidBytes, 10);
// and add clock sequence
int clockSeq = timer.getClockSequence();
uuidBytes[UUIDUtil.BYTE_OFFSET_CLOCK_SEQUENCE] = (byte) (clockSeq >> 8);
uuidBytes[UUIDUtil.BYTE_OFFSET_CLOCK_SEQUENCE+1] = (byte) clockSeq;
long l2 = UUIDUtil.gatherLong(uuidBytes, 8);
_uuidL2 = UUIDUtil.initUUIDSecondLong(l2);
_timer = timer;
}
/*
/**********************************************************************
/* Access to config
/**********************************************************************
*/
@Override
public UUIDType getType() { return UUIDType.TIME_BASED; }
public EthernetAddress getEthernetAddress() { return _ethernetAddress; }
/*
/**********************************************************************
/* UUID generation
/**********************************************************************
*/
/* As timer is not synchronized (nor _uuidBytes), need to sync; but most
* importantly, synchronize on timer which may also be shared between
* multiple instances
*/
@Override
public UUID generate()
{
final long rawTimestamp = _timer.getTimestamp();
// Time field components are kind of shuffled, need to slice:
int clockHi = (int) (rawTimestamp >>> 32);
int clockLo = (int) rawTimestamp;
// and dice
int midhi = (clockHi << 16) | (clockHi >>> 16);
// need to squeeze in type (4 MSBs in byte 6, clock hi)
midhi &= ~0xF000; // remove high nibble of 6th byte
midhi |= 0x1000; // type 1
long midhiL = (long) midhi;
midhiL = ((midhiL << 32) >>> 32); // to get rid of sign extension
// and reconstruct
long l1 = (((long) clockLo) << 32) | midhiL;
// last detail: must force 2 MSB to be '10'
return new UUID(l1, _uuidL2);
}
}
package com.fasterxml.uuid.impl;
import java.util.UUID;
import com.fasterxml.uuid.*;
/**
* Implementation of UUID generator that uses time/location based generation
* method field compatible with UUIDv1, reorderd for improved DB locality
* (variant 6).
* <p>
* As all JUG provided implementations, this generator is fully thread-safe.
* Additionally it can also be made externally synchronized with other instances
* (even ones running on other JVMs); to do this, use
* {@link com.fasterxml.uuid.ext.FileBasedTimestampSynchronizer} (or
* equivalent).
*
* @since 4.1
*/
public class TimeBasedReorderedGenerator extends NoArgGenerator
{
public static int BYTE_OFFSET_TIME_HIGH = 0;
public static int BYTE_OFFSET_TIME_MID = 4;
public static int BYTE_OFFSET_TIME_LOW = 7;
/*
/**********************************************************************
/* Configuration
/**********************************************************************
*/
protected final EthernetAddress _ethernetAddress;
/**
* Object used for synchronizing access to timestamps, to guarantee
* that timestamps produced by this generator are unique and monotonically increasings.
* Some implementations offer even stronger guarantees, for example that
* same guarantee holds between instances running on different JVMs (or
* with native code).
*/
protected final UUIDTimer _timer;
/**
* Base values for the second long (last 8 bytes) of UUID to construct
*/
protected final long _uuidL2;
/*
/**********************************************************************
/* Construction
/**********************************************************************
*/
/**
* @param ethAddr Hardware address (802.1) to use for generating
* spatially unique part of UUID. If system has more than one NIC,
*/
public TimeBasedReorderedGenerator(EthernetAddress ethAddr, UUIDTimer timer)
{
byte[] uuidBytes = new byte[16];
if (ethAddr == null) {
ethAddr = EthernetAddress.constructMulticastAddress();
}
// initialize baseline with MAC address info
_ethernetAddress = ethAddr;
_ethernetAddress.toByteArray(uuidBytes, 10);
// and add clock sequence
int clockSeq = timer.getClockSequence();
uuidBytes[UUIDUtil.BYTE_OFFSET_CLOCK_SEQUENCE] = (byte) (clockSeq >> 8);
uuidBytes[UUIDUtil.BYTE_OFFSET_CLOCK_SEQUENCE+1] = (byte) clockSeq;
long l2 = UUIDUtil.gatherLong(uuidBytes, 8);
_uuidL2 = UUIDUtil.initUUIDSecondLong(l2);
_timer = timer;
}
/*
/**********************************************************************
/* Access to config
/**********************************************************************
*/
@Override
public UUIDType getType() { return UUIDType.TIME_BASED_REORDERED; }
public EthernetAddress getEthernetAddress() { return _ethernetAddress; }
/*
/**********************************************************************
/* UUID generation
/**********************************************************************
*/
/* As timer is not synchronized (nor _uuidBytes), need to sync; but most
* importantly, synchronize on timer which may also be shared between
* multiple instances
*/
@Override
public UUID generate()
{
// Ok, get 60-bit timestamp (4 MSB are ignored)
final long rawTimestamp = _timer.getTimestamp();
// First: discard 4 MSB, next 32 bits (top of 60-bit timestamp) form the
// highest 32-bit segments
final long timestampHigh = (rawTimestamp >>> 28) << 32;
// and then bottom 28 bits split into mid (16 bits), low (12 bits)
final int timestampLow = (int) rawTimestamp;
// and then low part gets mixed with variant identifier
final int timeBottom = (((timestampLow >> 12) & 0xFFFF) << 16)
// and final 12 bits mixed with variant identifier
| 0x6000 | (timestampLow & 0xFFF);
long timeBottomL = (long) timeBottom;
timeBottomL = ((timeBottomL << 32) >>> 32); // to get rid of sign extension
// and reconstruct
long l1 = timestampHigh | timeBottomL;
return new UUID(l1, _uuidL2);
}
}
/**
Package that contains actual Java UUID Generator implementation classes,
including generators for different UUID types.
*/
package com.fasterxml.uuid.impl;
/*
Package that contains core (non-optional) Java UUID Generator API classes.
Implementation classes can be found from under {@link com.fasterxml.uuid.impl}.
<p>
The primary point is {@link com.fasterxml.uuid.Generators}, used to construct actual
generators, based on method to use and some optional arguments.
*/
package com.fasterxml.uuid;
package pps.core.common.bean;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
/**
* Spring Context 工具类
*
* @author lixueyan
*/
@Component
public class SpringContextUtils implements ApplicationContextAware {
public static ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
SpringContextUtils.applicationContext = applicationContext;
}
public static Object getBean(String name) {
return applicationContext.getBean(name);
}
public static <T> T getBean(Class<T> requiredType) {
return applicationContext.getBean(requiredType);
}
public static <T> T getBean(String name, Class<T> requiredType) {
return applicationContext.getBean(name, requiredType);
}
public static boolean containsBean(String name) {
return applicationContext.containsBean(name);
}
public static boolean isSingleton(String name) {
return applicationContext.isSingleton(name);
}
public static Class<? extends Object> getType(String name) {
return applicationContext.getType(name);
}
}
package pps.core.common.cache;
import xstartup.base.XContext;
import xstartup.base.util.XJsonUtils;
import xstartup.cache.XCacheLife;
import xstartup.cache.XCacheObject;
import xstartup.cache.XSingleCache;
import xstartup.core.base.annotation.XCacheKeyPrefix;
import java.util.function.Supplier;
@XCacheKeyPrefix("CONFIG_CACHE")
public class ConfigCache implements XCacheObject, XCacheLife {
/*
* 配置名称
* */
private String configName;
/*
* 配置值
* */
private String configValue;
public String getConfigName() {
return configName;
}
public void setConfigName(String configName) {
this.configName = configName;
}
public String getConfigValue() {
return configValue;
}
public void setConfigValue(String configValue) {
this.configValue = configValue;
}
@Override
public Integer getDuration() {
//30秒
return 30;
}
@Override
public String getCacheKey() {
return configName;
}
/**
* 获取缓存的token
*/
public static ConfigCache get(XContext context, String configName, boolean deleteOriginal, Supplier<String> valueProvider) {
ConfigCacheRefreshTool tool = ConfigCacheRefreshTool.get(ConfigCacheRefreshTool.class);
tool.setValueProvider(valueProvider);
ConfigCache cache = tool.find(context, configName, ConfigCache.class);
if( deleteOriginal){
try{
tool.delete(context, cache);
}catch(Exception e){
context.getLogger().error("delete cache exception.", e);
}
cache = tool.find(context, configName, ConfigCache.class);
}
return cache;
}
static class ConfigCacheRefreshTool extends XSingleCache<ConfigCache> {
private Supplier<String> valueProvider;
public Supplier<String> getValueProvider() {
return valueProvider;
}
public void setValueProvider(Supplier<String> valueProvider) {
this.valueProvider = valueProvider;
}
@Override
protected ConfigCache restore(XContext context, String cacheKey) {
//生成缓存对象
if(valueProvider != null){
ConfigCache cache = new ConfigCache();
cache.configName = cacheKey;
cache.configValue = valueProvider.get();
return cache;
}
return null;
}
}
}
package pps.core.common.cache;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.util.CollectionUtils;
import pps.core.common.entity.SysTradeInterfaceWhiteEnt;
import pps.core.common.mapper.SysTradeInterfaceWhiteMapper;
import xstartup.base.XContext;
import xstartup.base.util.XCopyUtils;
import xstartup.cache.XCacheLife;
import xstartup.cache.XCacheObject;
import xstartup.cache.XListCache;
import java.util.List;
/**
* 交易平台用户权限缓存
* 优先判断 用户权限,为空时判断角色权限
*/
public class TradeUserPermissionCache implements XCacheObject , XCacheLife {
private String serviceName;
private String methodName;
public TradeUserPermissionCache() {
}
public TradeUserPermissionCache(String serviceName, String methodName) {
this.serviceName = serviceName;
this.methodName = methodName;
}
public String getServiceName() {
return serviceName;
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
public String getMethodName() {
return methodName;
}
public void setMethodName(String methodName) {
this.methodName = methodName;
}
@Override
public String getCacheKey() {
return this.serviceName+"#"+this.methodName;
}
@Override
public Integer getDuration() {
//过期时间(秒)
// 1天
// return 24 * 3600;
// 5分钟
return 5 * 60;
}
/**
* 检查缓存是否存在指定的code
* @param context
* @param roleId
* @param serviceName
* @param methodName
* @return
*/
public static boolean exist(XContext context, Long roleId, String serviceName,String methodName){
return Tool.get(Tool.class).exist(context, roleId.toString(), serviceName+"#"+methodName, TradeUserPermissionCache.class);
}
/**
* 从缓存中读取
* @param context
* @param roleId
* @return
*/
public static List<TradeUserPermissionCache> list(XContext context, Long roleId){
return Tool.get(Tool.class).list(context, roleId.toString(), TradeUserPermissionCache.class);
}
/**
* 设置缓存
* @param context
* @param roleId
* @param caches
*/
public static void set(XContext context, Long roleId, List<TradeUserPermissionCache> caches){
Tool.get(Tool.class).set(context, roleId.toString(), caches);
}
/**
* 删除缓存
* @param context
* @param roleId
*/
public static void delete(XContext context, Long roleId){
Tool.get(Tool.class).delete(context, roleId.toString(), TradeUserPermissionCache.class);
}
static class Tool extends XListCache<TradeUserPermissionCache> {
@Override
protected List<TradeUserPermissionCache> restore(XContext context, String listKey) {
SysTradeInterfaceWhiteMapper whiteMapper = context.getBean(SysTradeInterfaceWhiteMapper.class);
QueryWrapper<SysTradeInterfaceWhiteEnt> whiteEntQueryWrapper = new QueryWrapper<>();
List<SysTradeInterfaceWhiteEnt> whiteEntList = whiteMapper.selectList(whiteEntQueryWrapper);
if(!CollectionUtils.isEmpty(whiteEntList)){
return XCopyUtils.copyNewList(whiteEntList,TradeUserPermissionCache.class);
}
return null;
}
}
}
package pps.core.common.config;
import pps.core.common.utils.TimeSpanChecker;
import xstartup.annotation.XConfig;
import xstartup.base.XContext;
import xstartup.config.XBooleanConfigItem;
import xstartup.config.XConfigMetadata;
@XConfig
public class AnalysisTransferConfig {
/**
* 是否使用微服务调用
*/
private static boolean useMq2Analysis = true;
private static TimeSpanChecker checker = new TimeSpanChecker(60, false);
public static boolean checkUseMq2AnalysisConfig(XContext context) {
// 使用mq发送消息
return true;
// try {
// if (checker.checkNow() && useMq2AnalysisConfig != null) {
// useMq2Analysis = useMq2AnalysisConfig.getValueNotNull(context);
// }
// return useMq2Analysis;
// } catch (Exception e) {
// return false;
// }
}
public static final XBooleanConfigItem useMq2AnalysisConfig = XConfigMetadata.register(TraceLogConfig.class,
"useMq2Analysis",
XBooleanConfigItem.class);
}
package pps.core.common.config;
import pps.core.common.utils.TimeSpanChecker;
import xstartup.annotation.XConfig;
import xstartup.base.XContext;
import xstartup.config.XBooleanConfigItem;
import xstartup.config.XConfigMetadata;
@XConfig
public class ExceptionDebugConfig {
/**
* 不显示诊断信息
*/
private static boolean dontShowExceptionDebug = false;
private static TimeSpanChecker checker = new TimeSpanChecker(60, false);
public static boolean checkDontShowExceptionDebug(XContext context){
if( checker.checkNow()){
dontShowExceptionDebug = dontShowExceptionDebugConfig.getValueNotNull(context);
}
return dontShowExceptionDebug;
}
public static final XBooleanConfigItem dontShowExceptionDebugConfig = XConfigMetadata.register(TraceLogConfig.class,
"dontShowExceptionDebug",
XBooleanConfigItem.class);
}
package pps.core.common.config;
import xstartup.annotation.XConfig;
import xstartup.config.XBooleanConfigItem;
import xstartup.config.XConfigMetadata;
@XConfig
public class FormTimeControlConfig {
public XBooleanConfigItem disableFormTimeControl = XConfigMetadata.register(FormTimeControlConfig.class,
"disableFormTimeControl",
XBooleanConfigItem.class);
}
package pps.core.common.config;
import xstartup.annotation.XConfig;
import xstartup.config.XConfigMetadata;
import xstartup.config.XIntegerConfigItem;
import xstartup.config.XStringConfigItem;
/**
* @author lixueyan
* @date 2022/8/4 0007 12:44
*/
/**
* mq topic 配置类
*/
@XConfig
public class MqConfig {
//消费时间间隔
public static final XIntegerConfigItem consumeInterval = XConfigMetadata.register(MqConfig.class,"consumeInterval",XIntegerConfigItem.class);
//访问日志topic
public static final XStringConfigItem accessLogMq = XConfigMetadata.register(MqConfig.class,"accessLogMq",XStringConfigItem.class);
//新老pps交互日志topic
public static final XStringConfigItem transferLogMq = XConfigMetadata.register(MqConfig.class,"transferLogMq",XStringConfigItem.class);
//新系统至老系统的表单数据mq通道
public static final XStringConfigItem newToOldFormMq = XConfigMetadata.register(MqConfig.class,"newToOldFormMq",XStringConfigItem.class);
//新系统至老系统的表单数据mq通道-开关(0:关,1:开)
public static final XIntegerConfigItem newToOldFormMqSwitch = XConfigMetadata.register(MqConfig.class,"newToOldFormMqSwitch",XIntegerConfigItem.class);
//新系统至分析系统的表单数据mq通道
public static final XStringConfigItem toAnalysisMq = XConfigMetadata.register(MqConfig.class,"toAnalysisMq",XStringConfigItem.class);
//新系统至分析系统的表单数据mq通道-开关(0:关,1:开)
public static final XIntegerConfigItem toAnalysisMqSwitch = XConfigMetadata.register(MqConfig.class,"toAnalysisMqSwitch",XIntegerConfigItem.class);
//新系统删除分析系统的表单数据mq通道
public static final XStringConfigItem removeAnalysisMq = XConfigMetadata.register(MqConfig.class,"removeAnalysisMq",XStringConfigItem.class);
//老pps 日指定mq topic
public static final XStringConfigItem oldToNewMq = XConfigMetadata.register(MqConfig.class,"oldToNewMq",XStringConfigItem.class);
//生成pdf topic
public static final XStringConfigItem createPDFMq = XConfigMetadata.register(MqConfig.class,"createPDFMq",XStringConfigItem.class);
//推送原油计量凭证 topic
public static final XStringConfigItem pushMeasureDataMq = XConfigMetadata.register(MqConfig.class,"pushMeasureDataMq",XStringConfigItem.class);
//推送原油计量凭证 topic
public static final XStringConfigItem pushSchedulDataMq = XConfigMetadata.register(MqConfig.class,"pushScheduleDataMq",XStringConfigItem.class);
//发送消息 topic
public static final XStringConfigItem sysInformSendMq = XConfigMetadata.register(MqConfig.class,"sysInformSendMq",XStringConfigItem.class);
//ack Ims topic
public static final XStringConfigItem ackImsMq = XConfigMetadata.register(MqConfig.class,"ackImsMq",XStringConfigItem.class);
//生成pdf topic
public static final XStringConfigItem CommonTraceLogMq = XConfigMetadata.register(MqConfig.class,"CommonTraceLogMq",XStringConfigItem.class);
}
package pps.core.common.config;
import xstartup.annotation.XConfig;
import xstartup.config.XConfigMetadata;
import xstartup.config.XIntegerConfigItem;
/**
* @author lixueyan
* @date 2022/8/4 0007 12:44
*/
/**
* obs 配置类
*/
@XConfig
public class ObsConfig {
//url 过期时间
public static final XIntegerConfigItem urlExpires = XConfigMetadata.register(ObsConfig.class,"urlExpires",XIntegerConfigItem.class);
}
package pps.core.common.config;
import pps.core.common.utils.TimeSpanChecker;
import xstartup.annotation.XConfig;
import xstartup.base.XContext;
import xstartup.config.XBooleanConfigItem;
import xstartup.config.XConfigMetadata;
@XConfig
public class OldPPSTransferConfig {
/**
* 是否使用微服务调用
*/
private static boolean useMq2OldPPS = false;
private static TimeSpanChecker checker = new TimeSpanChecker(60, false);
public static boolean checkUseMq2OldPPSConfig(XContext context){
return true;
// try{
// if( checker.checkNow() && useMq2OldPPSConfig != null){
// useMq2OldPPS = useMq2OldPPSConfig.getValueNotNull(context);
// }
// return useMq2OldPPS;
// }catch (Exception e){
// return false;
// }
}
public static final XBooleanConfigItem useMq2OldPPSConfig = XConfigMetadata.register(TraceLogConfig.class,
"useMq2OldPPS",
XBooleanConfigItem.class);
}
package pps.core.common.config;
import pps.core.common.utils.TimeSpanChecker;
import xstartup.annotation.XConfig;
import xstartup.base.XContext;
import xstartup.config.XBooleanConfigItem;
import xstartup.config.XConfigMetadata;
@XConfig
public class TraceLogConfig {
/**
* 是否使用微服务调用
*/
private static boolean blnTraceLog = true;
private static TimeSpanChecker checker = new TimeSpanChecker(60, false);
public static boolean checkEnableTraceLog(XContext context) {
try {
if (checker.checkNow() ) {
XBooleanConfigItem enableTraceLog = XConfigMetadata.register(TraceLogConfig.class,
"enabletracelog",
XBooleanConfigItem.class);
blnTraceLog = enableTraceLog.getValueNotNull(context);
}
return blnTraceLog;
} catch (Exception e) {
return false;
}
}
//跟踪日志配置
// public static final XBooleanConfigItem enableTraceLog = XConfigMetadata.register(TraceLogConfig.class,
// "enabletracelog",
// XBooleanConfigItem.class);
}
package pps.core.common.constant;
/**
* @author lixueyan
* @date 2022/8/30 0030 13:50
*/
public class BpmProcessCodeConstant {
public static final String PROCESS_CODE_TASK_PLAN_WEEK_SUBMIT = "PPS-TRQ-ZZYJHSH-001"; //周作业计划提交流程编码
public static final String PROCESS_CODE_TASK_PLAN_CHANGE = ""; //作业计划变更流程编码
public static final String PROCESS_CODE_TASK_PLAN_JJ_SUBMIT = "PPS-TRQ-JJZYJHSH-001"; //临时作业计划提交流程编码
public static final String PROCESS_CODE_TASK_PLAN_MONTH_SUBMIT = "PPS-TRQ-YDZYJHSH-001"; //月度作业计划提交流程编码
public static final String PROCESS_CODE_TASK_PLAN_YEAR_SUBMIT = "PPS-TRQ-NDZYJHSH-001"; //年度作业计划提交流程编码
}
package pps.core.common.constant;
/**
* 常量
*
* @author lixueyan
*/
public interface Constant {
int FLAG_TRUE = 1;
int FLAG_FALSE = 0;
/**
* 成功
*/
int SUCCESS = 1;
/**
* 失败
*/
int FAIL = 0;
/**
* 表单类型-草稿
*/
int FORMTEMPLATE_DRAFT = 1;
/**
* 表单类型-已发布
*/
int FORMTEMPLATE_COMMIT = 2;
/**
* 有子集
*/
int ISHASHCHILDREN_TRUE = 1;
/**
* 无子集
*/
int ISHASHCHILDREN_FALSE = 0;
/**
* 菜单根节点标识
*/
Long MENU_ROOT = 0L;
/**
* 部门根节点标识
*/
Long DEPT_ROOT = 0L;
/**
* 升序
*/
String ASC = "asc";
/**
* 降序
*/
String DESC = "desc";
/**
* 创建时间字段名
*/
String CREATE_DATE = "create_date";
/**
* 数据权限过滤
*/
String SQL_FILTER = "sqlFilter";
/**
* 当前页码
*/
String PAGE = "page";
/**
* 每页显示记录数
*/
String LIMIT = "limit";
/**
* 排序字段
*/
String ORDER_FIELD = "orderField";
/**
* 排序方式
*/
String ORDER = "order";
/**
* token header
*/
String TOKEN_HEADER = "token";
/**
* 云存储配置KEY
*/
String CLOUD_STORAGE_CONFIG_KEY = "CLOUD_STORAGE_CONFIG_KEY";
/**
* 定时任务状态
*/
enum ScheduleStatus {
/**
* 暂停
*/
PAUSE(0),
/**
* 正常
*/
NORMAL(1);
private int value;
ScheduleStatus(int value) {
this.value = value;
}
public int getValue() {
return value;
}
}
/**
* 云服务商
*/
enum CloudService {
/**
* 七牛云
*/
QINIU(1),
/**
* 阿里云
*/
ALIYUN(2),
/**
* 腾讯云
*/
QCLOUD(3);
private int value;
CloudService(int value) {
this.value = value;
}
public int getValue() {
return value;
}
}
}
package pps.core.common.constant;
/**
* @author lixueyan
* @date 2023/2/17 0017 13:04
*/
public class LoginConstant {
public static final Long LOGIN_FLAG_SIMULATE = 1000000L; //模拟登陆
public static final Long LOGIN_FLAG_TRADE = 2000000L; //交易平台登陆
}
package pps.core.common.constant;
public class UserConstant {
//超级管理员
public static final Integer ISSUPERADMIN_TRUE = 1;
//普通角色
public static final Integer ISSUPERADMIN_FALSE = 0;
}
package pps.core.common.data;
import java.util.HashMap;
public class FormBizDataRecord {
// 表字段
private HashMap<String, Object> fields;
// 是否新记录
private boolean isNewRecord;
public HashMap<String, Object> getFields() {
return fields;
}
public void setFields(HashMap<String, Object> fields) {
this.fields = fields;
}
public boolean isNewRecord() {
return isNewRecord;
}
public void setNewRecord(boolean newRecord) {
isNewRecord = newRecord;
}
}
package pps.core.common.data;
import java.util.HashSet;
public class FormBizDataRemovedRecordId {
// id 列表
private HashSet<String> ids;
public HashSet<String> getIds() {
return ids;
}
public void setIds(HashSet<String> ids) {
this.ids = ids;
}
}
package pps.core.common.data;
import xstartup.annotation.XText;
import java.math.BigDecimal;
import java.util.Date;
public class FormBizDataValue {
@XText("表单id")
private String formInputId;
@XText("点定义id")
private String dataDefineId;
@XText("日期")
private Date dataDate;
@XText("点值(数值)")
private BigDecimal numericValue;
@XText("状态(0:无效,1:有效)")
private String status;
@XText("点值(文本)")
private String textValue;
private String stationId;
private String ouId;
public String getFormInputId() {
return formInputId;
}
public void setFormInputId(String formInputId) {
this.formInputId = formInputId;
}
public String getDataDefineId() {
return dataDefineId;
}
public void setDataDefineId(String dataDefineId) {
this.dataDefineId = dataDefineId;
}
public Date getDataDate() {
return dataDate;
}
public void setDataDate(Date dataDate) {
this.dataDate = dataDate;
}
public BigDecimal getNumericValue() {
return numericValue;
}
public void setNumericValue(BigDecimal numericValue) {
this.numericValue = numericValue;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getTextValue() {
return textValue;
}
public void setTextValue(String textValue) {
this.textValue = textValue;
}
public String getStationId() {
return stationId;
}
public void setStationId(String stationId) {
this.stationId = stationId;
}
public String getOuId() {
return ouId;
}
public void setOuId(String ouId) {
this.ouId = ouId;
}
}
package pps.core.common.data;
public class IdWithName {
private String id;
private String name;
public IdWithName() {
}
public IdWithName(String id, String name) {
this.id = id;
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package pps.core.common.data;
public class LabelWithName {
private String label;
private String name;
public LabelWithName() {
}
public LabelWithName(String labelOrName) {
this.label = labelOrName;
this.name = labelOrName;
}
public LabelWithName(String label, String name) {
this.label = label;
this.name = name;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package pps.core.common.entity;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import xstartup.annotation.XText;
@TableName("base_sys_config")
public class BaseSysConfigEnt implements Serializable {
@TableId(type = IdType.ASSIGN_UUID)
private String id;
@XText("配置名称")
@TableField
private String name;
@XText("配置key")
@TableField
private String key;
@XText("配置值")
@TableField
private String value;
@XText("创建人")
@TableField
private String createById;
@XText("创建人名称")
@TableField
private String createByName;
@XText("修改人")
@TableField
private String modifyById;
@XText("修改人名称")
@TableField
private String modifyByName;
@XText("组织机构id")
@TableField
private String ouId;
public String getId() {
return this.id;
}
public void setId(String value) {
this.id = value;
}
public String getName() {
return this.name;
}
public void setName(String value) {
this.name = value;
}
public String getKey() {
return this.key;
}
public void setKey(String value) {
this.key = value;
}
public String getValue() {
return this.value;
}
public void setValue(String value) {
this.value = value;
}
public String getCreateById() {
return this.createById;
}
public void setCreateById(String value) {
this.createById = value;
}
public String getCreateByName() {
return this.createByName;
}
public void setCreateByName(String value) {
this.createByName = value;
}
public String getModifyById() {
return this.modifyById;
}
public void setModifyById(String value) {
this.modifyById = value;
}
public String getModifyByName() {
return this.modifyByName;
}
public void setModifyByName(String value) {
this.modifyByName = value;
}
public String getOuId() {
return ouId;
}
public void setOuId(String ouId) {
this.ouId = ouId;
}
}
package pps.core.common.entity;
import java.io.Serializable;
import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableField;
import xstartup.annotation.XText;
public class BaseSysConfigView implements Serializable {
@TableField
private String id;
@XText("配置名称")
@TableField
private String name;
@XText("配置key")
@TableField
private String key;
@XText("配置值")
@TableField
private String value;
@XText("创建人")
@TableField
private String createById;
@XText("创建人名称")
@TableField
private String createByName;
@XText("修改人")
@TableField
private String modifyById;
@XText("修改人名称")
@TableField
private String modifyByName;
@XText("组织机构id")
@TableField
private String ouId;
public String getId() {
return this.id;
}
public void setId(String value) {
this.id = value;
}
public String getName() {
return this.name;
}
public void setName(String value) {
this.name = value;
}
public String getKey() {
return this.key;
}
public void setKey(String value) {
this.key = value;
}
public String getValue() {
return this.value;
}
public void setValue(String value) {
this.value = value;
}
public String getCreateById() {
return this.createById;
}
public void setCreateById(String value) {
this.createById = value;
}
public String getCreateByName() {
return this.createByName;
}
public void setCreateByName(String value) {
this.createByName = value;
}
public String getModifyById() {
return this.modifyById;
}
public void setModifyById(String value) {
this.modifyById = value;
}
public String getModifyByName() {
return this.modifyByName;
}
public void setModifyByName(String value) {
this.modifyByName = value;
}
public String getOuId() {
return ouId;
}
public void setOuId(String ouId) {
this.ouId = ouId;
}
}
package pps.core.common.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import xstartup.annotation.XText;
import java.io.Serializable;
import java.util.Date;
@TableName("base_transfer_log")
public class BaseTransferLogEnt implements Serializable {
@TableId(type = IdType.ASSIGN_UUID)
private String id;
@XText("topic")
@TableField
private String topicName;
@XText("作用域名称")
@TableField
private String mqMessage;
@XText("执行时间")
@TableField
private Date createTime;
@XText("异常信息")
@TableField
private String exceptionInfo;
public String getId() {
return this.id;
}
public void setId(String value) {
this.id = value;
}
public String getTopicName() {
return topicName;
}
public void setTopicName(String topicName) {
this.topicName = topicName;
}
public String getMqMessage() {
return mqMessage;
}
public void setMqMessage(String mqMessage) {
this.mqMessage = mqMessage;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getExceptionInfo() {
return exceptionInfo;
}
public void setExceptionInfo(String exceptionInfo) {
this.exceptionInfo = exceptionInfo;
}
}
package pps.core.common.entity;
import xstartup.base.XContext;
import java.util.Date;
public interface ICommonEnt {
default String getCreateUserid(){
return "";
}
default void setCreateUserid(String value){}
String getCreateName();
void setCreateName(String value);
Date getCreateTime();
void setCreateTime(Date value);
default String getModifyUserid(){
return "";
}
default void setModifyUserid(String value){
}
default String getModifyByName(){
return "";
}
default void setModifyByName(String value){
}
default String getModifyName(){
return "";
}
default void setModifyName(String value){
}
Date getModifyTime();
void setModifyTime(Date value);
default void updateCreateInfo(XContext context){
this.setCreateTime(new Date());
this.setCreateName(context.getUser().getName());
this.setCreateUserid(context.getUser().getCode());
}
default void updateModifyInfo(XContext context){
this.setModifyTime(new Date());
this.setModifyByName(context.getUser().getName());
this.setModifyUserid(context.getUser().getCode());
this.setModifyName(context.getUser().getName());
this.setModifyTime(new Date());
}
}
package pps.core.common.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
import pps.core.common.entity.BaseSysConfigEnt;
@Repository(value="pps.core.common.mapper.BaseSysConfigMapper")
public interface BaseSysConfigMapper extends BaseMapper<BaseSysConfigEnt> {
}
package pps.core.common.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
import pps.core.common.entity.BaseSysConfigView;
import java.util.List;
@Repository(value="pps.core.common.mapper.BaseSysConfigViewMapper")
public interface BaseSysConfigViewMapper {
BaseSysConfigView selectOne(BaseSysConfigView record);
List<BaseSysConfigView> selectList(BaseSysConfigView record);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment