commit
2b23163569
65 changed files with 5351 additions and 0 deletions
@ -0,0 +1,92 @@ |
|||||
|
<?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>oms-biz</artifactId> |
||||
|
<groupId>com.yxt</groupId> |
||||
|
<version>1.0-SNAPSHOT</version> |
||||
|
</parent> |
||||
|
<modelVersion>4.0.0</modelVersion> |
||||
|
|
||||
|
<groupId>com.yxt.gateway</groupId> |
||||
|
<artifactId>gateway</artifactId> |
||||
|
|
||||
|
<properties> |
||||
|
<maven.compiler.source>8</maven.compiler.source> |
||||
|
<maven.compiler.target>8</maven.compiler.target> |
||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
||||
|
</properties> |
||||
|
<dependencies> |
||||
|
<dependency> |
||||
|
<groupId>io.jsonwebtoken</groupId> |
||||
|
<artifactId>jjwt</artifactId> |
||||
|
<version>0.9.0</version> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>org.springframework.cloud</groupId> |
||||
|
<artifactId>spring-cloud-starter-gateway</artifactId> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>com.alibaba.cloud</groupId> |
||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>org.projectlombok</groupId> |
||||
|
<artifactId>lombok</artifactId> |
||||
|
<version>1.18.24</version> |
||||
|
<optional>true</optional> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>org.springframework</groupId> |
||||
|
<artifactId>spring-webmvc</artifactId> |
||||
|
</dependency> |
||||
|
<!--引入redis--> |
||||
|
<dependency> |
||||
|
<groupId>org.springframework.boot</groupId> |
||||
|
<artifactId>spring-boot-starter-data-redis</artifactId> |
||||
|
<exclusions> |
||||
|
<exclusion> |
||||
|
<groupId>io.lettuce</groupId> |
||||
|
<artifactId>lettuce-core</artifactId> |
||||
|
</exclusion> |
||||
|
</exclusions> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>redis.clients</groupId> |
||||
|
<artifactId>jedis</artifactId> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>com.alibaba</groupId> |
||||
|
<artifactId>fastjson</artifactId> |
||||
|
</dependency> |
||||
|
|
||||
|
|
||||
|
</dependencies> |
||||
|
|
||||
|
<build> |
||||
|
<plugins> |
||||
|
<plugin> |
||||
|
<groupId>org.springframework.boot</groupId> |
||||
|
<artifactId>spring-boot-maven-plugin</artifactId> |
||||
|
<version>2.5.6</version> |
||||
|
<executions> |
||||
|
<execution> |
||||
|
<goals> |
||||
|
<goal>repackage</goal> |
||||
|
</goals> |
||||
|
</execution> |
||||
|
</executions> |
||||
|
</plugin> |
||||
|
</plugins> |
||||
|
<resources> |
||||
|
<resource> |
||||
|
<directory>src/main/resources</directory> |
||||
|
<includes> |
||||
|
<include>**/*.yml</include> |
||||
|
</includes> |
||||
|
<filtering>false</filtering> |
||||
|
</resource> |
||||
|
</resources> |
||||
|
</build> |
||||
|
</project> |
@ -0,0 +1,124 @@ |
|||||
|
package com.yxt.oms; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSON; |
||||
|
import com.yxt.oms.utils.*; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.cloud.gateway.filter.GatewayFilterChain; |
||||
|
import org.springframework.cloud.gateway.filter.GlobalFilter; |
||||
|
import org.springframework.core.Ordered; |
||||
|
import org.springframework.core.io.buffer.DataBufferFactory; |
||||
|
import org.springframework.http.HttpStatus; |
||||
|
import org.springframework.http.MediaType; |
||||
|
import org.springframework.http.server.reactive.ServerHttpRequest; |
||||
|
import org.springframework.http.server.reactive.ServerHttpResponse; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
import org.springframework.web.server.ServerWebExchange; |
||||
|
import reactor.core.publisher.Mono; |
||||
|
|
||||
|
import static com.yxt.oms.utils.HttpStatus.OVERDUE; |
||||
|
|
||||
|
/** |
||||
|
* @author dimengzhe |
||||
|
* @date 2020/12/2 9:52 |
||||
|
* @description 网关鉴权 |
||||
|
* 1.某些接口不需要不进行登录验证,如登录,注册,获取验证码等接口。(uri白名单) |
||||
|
* 2.某些接口需要登录验证,但是不需要刷新token有效时间,如客户端轮询请求的接口。 |
||||
|
* 3.特定场景下IP黑、白名单。 |
||||
|
* 4.处于安全考虑的接口流量控制。 |
||||
|
*/ |
||||
|
@Component |
||||
|
public class AuthFilter implements GlobalFilter, Ordered { |
||||
|
|
||||
|
private static final Logger log = LoggerFactory.getLogger(AuthFilter.class); |
||||
|
//过期时间设置为4小时
|
||||
|
private final static long EXPIRE_TIME = Constants.TOKEN_EXPIRE * 60; |
||||
|
private final static long EXPIRE_TIME_APP = Constants.TOKEN_EXPIRE_APP * 60; |
||||
|
|
||||
|
// 排除过滤的 uri 地址,nacos自行添加
|
||||
|
@Autowired |
||||
|
private IgnoreWhiteProperties ignoreWhite; |
||||
|
@Autowired |
||||
|
private RedisUtil redisUtil; |
||||
|
/* |
||||
|
redis中数据存储结构为两个键值对 |
||||
|
键为用户ID,值为用户token,可以通过用户ID查询用户token,实现立刻失效用户token功能。 |
||||
|
键为用户token,值为用户数据,实现token有效性,用户数据缓存功能。 |
||||
|
*/ |
||||
|
|
||||
|
@Override |
||||
|
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { |
||||
|
String url = exchange.getRequest().getURI().getPath(); |
||||
|
//1.uri白名单。 跳过不需要验证的路径
|
||||
|
if (StringUtils.matches(url, ignoreWhite.getWhites())) { |
||||
|
return chain.filter(exchange); |
||||
|
} else if (StringUtils.matchesTwo(url, ignoreWhite.getWhitesTwo())) { |
||||
|
return chain.filter(exchange); |
||||
|
} |
||||
|
//2.验证有无令牌。 从请求的header中获取token
|
||||
|
String token = getToken(exchange.getRequest()); |
||||
|
if (StringUtils.isBlank(token)) { |
||||
|
return setUnauthorizedResponse(exchange, "令牌不能为空"); |
||||
|
} |
||||
|
//3.验证token是否有效。(a.验证token是否合法 b.验证token是否过期)
|
||||
|
//从redis缓存中获取key对应的内容
|
||||
|
String userName = redisUtil.get(token); |
||||
|
|
||||
|
if (StringUtils.isBlank(userName)) { |
||||
|
|
||||
|
return setUnauthorizedResponse(exchange, "登录状态已过期"); |
||||
|
} |
||||
|
//验签:需要验证token中的签名是否与用户sid一致,后台用密钥+userSid+token除签名以外的内容,重新生成签名,与token中的签名进行比较
|
||||
|
|
||||
|
//刷新token过期日期
|
||||
|
if (token.contains("App")) { |
||||
|
redisUtil.expire(token, EXPIRE_TIME_APP); |
||||
|
} else { |
||||
|
redisUtil.expire(token, EXPIRE_TIME); |
||||
|
} |
||||
|
|
||||
|
// 在请求中增加用户信息
|
||||
|
ServerHttpRequest mutableReq = exchange.getRequest().mutate() |
||||
|
.header(CacheConstants.DETAILS_USERNAME, userName).build(); |
||||
|
ServerWebExchange mutableExchange = exchange.mutate().request(mutableReq).build(); |
||||
|
return chain.filter(mutableExchange); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 鉴权异常处理 |
||||
|
* |
||||
|
* @param exchange |
||||
|
* @param msg |
||||
|
* @return |
||||
|
*/ |
||||
|
private Mono<Void> setUnauthorizedResponse(ServerWebExchange exchange, String msg) { |
||||
|
ServerHttpResponse response = exchange.getResponse(); |
||||
|
response.getHeaders().setContentType(MediaType.APPLICATION_JSON); |
||||
|
response.setStatusCode(HttpStatus.OK); |
||||
|
|
||||
|
log.error("[鉴权异常处理]请求路径:{}", exchange.getRequest().getPath()); |
||||
|
|
||||
|
return response.writeWith(Mono.fromSupplier(() -> { |
||||
|
DataBufferFactory bufferFactory = response.bufferFactory(); |
||||
|
// return bufferFactory.wrap(JSON.toJSONBytes(com.yxt.anrui.utils.HttpStatus.OVERDUE));
|
||||
|
return bufferFactory.wrap(JSON.toJSONBytes(ResultBean.fireFail().setCode(OVERDUE).setMsg(msg))); |
||||
|
})); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取请求token |
||||
|
*/ |
||||
|
private String getToken(ServerHttpRequest request) { |
||||
|
String token = request.getHeaders().getFirst(CacheConstants.HEADER); |
||||
|
// if (StringUtils.isNotEmpty(token) && token.startsWith(CacheConstants.TOKEN_PREFIX)) {
|
||||
|
// token = token.replace(CacheConstants.TOKEN_PREFIX, "");
|
||||
|
// }
|
||||
|
return token; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public int getOrder() { |
||||
|
return 0; |
||||
|
} |
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
package com.yxt.oms; |
||||
|
|
||||
|
import org.springframework.boot.SpringApplication; |
||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication; |
||||
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; |
||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date ${DATE} ${TIME} |
||||
|
*/ |
||||
|
|
||||
|
@EnableDiscoveryClient |
||||
|
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) |
||||
|
public class GatewayApplication { |
||||
|
public static void main(String[] args) { |
||||
|
SpringApplication.run(GatewayApplication.class, args); |
||||
|
}} |
@ -0,0 +1,300 @@ |
|||||
|
package com.yxt.oms; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.dao.DataAccessException; |
||||
|
import org.springframework.data.redis.connection.RedisConnection; |
||||
|
import org.springframework.data.redis.connection.RedisStringCommands; |
||||
|
import org.springframework.data.redis.core.*; |
||||
|
import org.springframework.data.redis.core.types.Expiration; |
||||
|
import org.springframework.data.redis.serializer.RedisSerializer; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.List; |
||||
|
import java.util.Set; |
||||
|
import java.util.concurrent.TimeUnit; |
||||
|
|
||||
|
/** |
||||
|
* @author dimengzhe |
||||
|
* @date 2020/9/9 17:35 |
||||
|
* @description redis工具类 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class RedisUtil { |
||||
|
|
||||
|
@Autowired |
||||
|
private RedisTemplate redisTemplate; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 字符串类型:根据key设置value值,如果key中的value存在,那么返回false |
||||
|
* |
||||
|
* @param key |
||||
|
* @param value |
||||
|
* @return |
||||
|
*/ |
||||
|
public Boolean setnx(final String key, final String value, final long expration, final TimeUnit timeUnit) { |
||||
|
return (Boolean) redisTemplate.execute(new RedisCallback<Boolean>() { |
||||
|
@Override |
||||
|
public Boolean doInRedis(RedisConnection redisConnection) throws DataAccessException { |
||||
|
RedisSerializer<String> redisSerializer = redisTemplate.getStringSerializer(); |
||||
|
byte keys[] = redisSerializer.serialize(key); |
||||
|
byte values[] = redisSerializer.serialize(value); |
||||
|
return redisConnection.set(keys, values, Expiration.from(expration, timeUnit), RedisStringCommands.SetOption.SET_IF_ABSENT); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 写入缓存 |
||||
|
* |
||||
|
* @param key |
||||
|
* @param value |
||||
|
* @return |
||||
|
*/ |
||||
|
public boolean set(final String key, final String value) { |
||||
|
|
||||
|
boolean result = (boolean) redisTemplate.execute(new RedisCallback<Boolean>() { |
||||
|
@Override |
||||
|
public Boolean doInRedis(RedisConnection connection) throws DataAccessException { |
||||
|
RedisSerializer<String> serializer = redisTemplate.getStringSerializer(); |
||||
|
connection.set(serializer.serialize(key), serializer.serialize(value)); |
||||
|
return true; |
||||
|
} |
||||
|
}); |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 写入缓存设置时效时间 |
||||
|
* |
||||
|
* @param key |
||||
|
* @param value |
||||
|
* @return |
||||
|
*/ |
||||
|
public boolean set(final String key, Object value, Long expireTime) { |
||||
|
boolean result = false; |
||||
|
try { |
||||
|
ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue(); |
||||
|
operations.set(key, value); |
||||
|
redisTemplate.expire(key, expireTime, TimeUnit.SECONDS); |
||||
|
result = true; |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
/** |
||||
|
* 刷新缓存到期时间 |
||||
|
* @param key |
||||
|
* @param expire |
||||
|
* @return |
||||
|
*/ |
||||
|
public boolean expire(String key, long expire) { |
||||
|
return redisTemplate.expire(key, expire, TimeUnit.SECONDS); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 读取缓存 |
||||
|
* |
||||
|
* @param key |
||||
|
* @return |
||||
|
*/ |
||||
|
public String get(final String key) { |
||||
|
String result = (String) redisTemplate.execute(new RedisCallback<String>() { |
||||
|
@Override |
||||
|
public String doInRedis(RedisConnection connection) throws DataAccessException { |
||||
|
RedisSerializer<String> serializer = redisTemplate.getStringSerializer(); |
||||
|
byte[] value = connection.get(serializer.serialize(key)); |
||||
|
return serializer.deserialize(value); |
||||
|
} |
||||
|
}); |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 正则获取key集合 |
||||
|
* |
||||
|
* @param pattern |
||||
|
* @return |
||||
|
*/ |
||||
|
public Set<String> keys(String pattern) { |
||||
|
Set<String> keys = redisTemplate.keys(pattern); |
||||
|
return keys; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 批量删除对应的value |
||||
|
* |
||||
|
* @param keys |
||||
|
*/ |
||||
|
public void remove(final String... keys) { |
||||
|
for (String key : keys) { |
||||
|
remove(key); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 批量删除key |
||||
|
* |
||||
|
* @param pattern |
||||
|
*/ |
||||
|
public void removePattern(final String pattern) { |
||||
|
Set<Serializable> keys = redisTemplate.keys(pattern); |
||||
|
if (keys.size() > 0) { |
||||
|
redisTemplate.delete(keys); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
public Long remove(final String key) { |
||||
|
return (Long) redisTemplate.execute(new RedisCallback<Long>() { |
||||
|
@Override |
||||
|
public Long doInRedis(RedisConnection redisConnection) throws DataAccessException { |
||||
|
RedisSerializer<String> serializer = redisTemplate.getStringSerializer(); |
||||
|
byte keys[] = serializer.serialize(key); |
||||
|
return redisConnection.del(keys); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 判断缓存中是否有对应的value |
||||
|
* |
||||
|
* @param key |
||||
|
* @return |
||||
|
*/ |
||||
|
public boolean exists(final String key) { |
||||
|
return redisTemplate.hasKey(key); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 哈希 添加 |
||||
|
* |
||||
|
* @param key |
||||
|
* @param hashKey |
||||
|
* @param value |
||||
|
*/ |
||||
|
public void hmSet(String key, Object hashKey, Object value) { |
||||
|
HashOperations<String, Object, Object> hash = redisTemplate.opsForHash(); |
||||
|
hash.put(key, hashKey, value); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 哈希获取数据 |
||||
|
* |
||||
|
* @param key |
||||
|
* @param hashKey |
||||
|
* @return |
||||
|
*/ |
||||
|
public String hmGet(String key, Object hashKey) { |
||||
|
HashOperations<String, String, String> hash = redisTemplate.opsForHash(); |
||||
|
return hash.get(key, hashKey); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取哈希 keys |
||||
|
* |
||||
|
* @param key |
||||
|
* @return |
||||
|
*/ |
||||
|
public Set<String> hmGetKeys(String key) { |
||||
|
HashOperations<String, String, String> hash = redisTemplate.opsForHash(); |
||||
|
return hash.keys(key); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除集合中的key |
||||
|
* |
||||
|
* @param key |
||||
|
* @param hashKey |
||||
|
*/ |
||||
|
public void hmDelete(String key, Object hashKey) { |
||||
|
HashOperations<String, Object, Object> hash = redisTemplate.opsForHash(); |
||||
|
hash.delete(key, hashKey); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 列表添加 |
||||
|
* |
||||
|
* @param k |
||||
|
* @param v |
||||
|
*/ |
||||
|
public void lPush(String k, Object v) { |
||||
|
ListOperations<String, Object> list = redisTemplate.opsForList(); |
||||
|
list.rightPush(k, v); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 列表获取 |
||||
|
* |
||||
|
* @param k |
||||
|
* @param l |
||||
|
* @param l1 |
||||
|
* @return |
||||
|
*/ |
||||
|
public List<Object> lRange(String k, long l, long l1) { |
||||
|
ListOperations<String, Object> list = redisTemplate.opsForList(); |
||||
|
return list.range(k, l, l1); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 集合添加 |
||||
|
* |
||||
|
* @param key |
||||
|
* @param value |
||||
|
*/ |
||||
|
public void add(String key, Object value) { |
||||
|
SetOperations<String, Object> set = redisTemplate.opsForSet(); |
||||
|
set.add(key, value); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 集合获取 |
||||
|
* |
||||
|
* @param key |
||||
|
* @return |
||||
|
*/ |
||||
|
public Set<Object> setMembers(String key) { |
||||
|
SetOperations<String, Object> set = redisTemplate.opsForSet(); |
||||
|
return set.members(key); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 有序集合添加 |
||||
|
* |
||||
|
* @param key |
||||
|
* @param value |
||||
|
* @param scoure |
||||
|
*/ |
||||
|
public void zAdd(String key, Object value, double scoure) { |
||||
|
ZSetOperations<String, Object> zset = redisTemplate.opsForZSet(); |
||||
|
zset.add(key, value, scoure); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 有序集合获取 |
||||
|
* |
||||
|
* @param key |
||||
|
* @param scoure |
||||
|
* @param scoure1 |
||||
|
* @return |
||||
|
*/ |
||||
|
public Set<Object> rangeByScore(String key, double scoure, double scoure1) { |
||||
|
ZSetOperations<String, Object> zset = redisTemplate.opsForZSet(); |
||||
|
return zset.rangeByScore(key, scoure, scoure1); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 实现命令:TTL key 以秒为单位,返回给定key的剩余生存时间 |
||||
|
* @param key |
||||
|
* @return |
||||
|
*/ |
||||
|
public long ttl(String key) { |
||||
|
return redisTemplate.getExpire(key); |
||||
|
} |
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
package com.yxt.oms.utils; |
||||
|
|
||||
|
/** |
||||
|
* @author dimengzhe |
||||
|
* @date 2020/12/2 9:58 |
||||
|
* @description 缓存的key 常量 |
||||
|
*/ |
||||
|
|
||||
|
public class CacheConstants { |
||||
|
|
||||
|
/** |
||||
|
* 令牌自定义标识 |
||||
|
*/ |
||||
|
public static final String HEADER = "token"; |
||||
|
|
||||
|
/** |
||||
|
* 令牌前缀 |
||||
|
*/ |
||||
|
public static final String TOKEN_PREFIX = "Bearer "; |
||||
|
|
||||
|
/** |
||||
|
* 用户名字段 |
||||
|
*/ |
||||
|
public static final String DETAILS_USERNAME = "userName"; |
||||
|
} |
@ -0,0 +1,86 @@ |
|||||
|
package com.yxt.oms.utils; |
||||
|
|
||||
|
import java.nio.charset.Charset; |
||||
|
import java.nio.charset.StandardCharsets; |
||||
|
|
||||
|
/** |
||||
|
* @author dimengzhe |
||||
|
* @date 2020/12/2 10:02 |
||||
|
* @description |
||||
|
*/ |
||||
|
|
||||
|
public class CharsetKit { |
||||
|
|
||||
|
/** ISO-8859-1 */ |
||||
|
public static final String ISO_8859_1 = "ISO-8859-1"; |
||||
|
/** UTF-8 */ |
||||
|
public static final String UTF_8 = "UTF-8"; |
||||
|
/** GBK */ |
||||
|
public static final String GBK = "GBK"; |
||||
|
|
||||
|
/** ISO-8859-1 */ |
||||
|
public static final Charset CHARSET_ISO_8859_1 = Charset.forName(ISO_8859_1); |
||||
|
/** UTF-8 */ |
||||
|
public static final Charset CHARSET_UTF_8 = Charset.forName(UTF_8); |
||||
|
/** GBK */ |
||||
|
public static final Charset CHARSET_GBK = Charset.forName(GBK); |
||||
|
|
||||
|
/** |
||||
|
* 转换为Charset对象 |
||||
|
* |
||||
|
* @param charset 字符集,为空则返回默认字符集 |
||||
|
* @return Charset |
||||
|
*/ |
||||
|
public static Charset charset(String charset) |
||||
|
{ |
||||
|
return StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换字符串的字符集编码 |
||||
|
* |
||||
|
* @param source 字符串 |
||||
|
* @param srcCharset 源字符集,默认ISO-8859-1 |
||||
|
* @param destCharset 目标字符集,默认UTF-8 |
||||
|
* @return 转换后的字符集 |
||||
|
*/ |
||||
|
public static String convert(String source, String srcCharset, String destCharset) |
||||
|
{ |
||||
|
return convert(source, Charset.forName(srcCharset), Charset.forName(destCharset)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换字符串的字符集编码 |
||||
|
* |
||||
|
* @param source 字符串 |
||||
|
* @param srcCharset 源字符集,默认ISO-8859-1 |
||||
|
* @param destCharset 目标字符集,默认UTF-8 |
||||
|
* @return 转换后的字符集 |
||||
|
*/ |
||||
|
public static String convert(String source, Charset srcCharset, Charset destCharset) |
||||
|
{ |
||||
|
if (null == srcCharset) |
||||
|
{ |
||||
|
srcCharset = StandardCharsets.ISO_8859_1; |
||||
|
} |
||||
|
|
||||
|
if (null == destCharset) |
||||
|
{ |
||||
|
destCharset = StandardCharsets.UTF_8; |
||||
|
} |
||||
|
|
||||
|
if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset)) |
||||
|
{ |
||||
|
return source; |
||||
|
} |
||||
|
return new String(source.getBytes(srcCharset), destCharset); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @return 系统字符集编码 |
||||
|
*/ |
||||
|
public static String systemCharset() |
||||
|
{ |
||||
|
return Charset.defaultCharset().name(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
package com.yxt.oms.utils; |
||||
|
|
||||
|
/** |
||||
|
* @author dimengzhe |
||||
|
* @date 2020/12/2 9:56 |
||||
|
* @description 通用常量信息 |
||||
|
*/ |
||||
|
|
||||
|
public class Constants { |
||||
|
|
||||
|
/** |
||||
|
* 成功标记 |
||||
|
*/ |
||||
|
public static final Integer SUCCESS = 200; |
||||
|
|
||||
|
/** |
||||
|
* 失败标记 |
||||
|
*/ |
||||
|
public static final Integer FAIL = 5000; |
||||
|
|
||||
|
public static final boolean fail = false; |
||||
|
public static final boolean success = true; |
||||
|
|
||||
|
/** |
||||
|
* 令牌有效期(分钟) |
||||
|
*/ |
||||
|
public final static long TOKEN_EXPIRE = 4*60; |
||||
|
public final static long TOKEN_EXPIRE_APP = 15*24*60; |
||||
|
} |
@ -0,0 +1,999 @@ |
|||||
|
package com.yxt.oms.utils; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
import java.math.BigInteger; |
||||
|
import java.nio.ByteBuffer; |
||||
|
import java.nio.charset.Charset; |
||||
|
import java.text.NumberFormat; |
||||
|
import java.util.Set; |
||||
|
|
||||
|
/** |
||||
|
* @author dimengzhe |
||||
|
* @date 2020/12/2 10:01 |
||||
|
* @description |
||||
|
*/ |
||||
|
|
||||
|
public class Convert { |
||||
|
|
||||
|
/** |
||||
|
* 转换为字符串<br> |
||||
|
* 如果给定的值为null,或者转换失败,返回默认值<br> |
||||
|
* 转换失败不会报错 |
||||
|
* |
||||
|
* @param value 被转换的值 |
||||
|
* @param defaultValue 转换错误时的默认值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static String toStr(Object value, String defaultValue) |
||||
|
{ |
||||
|
if (null == value) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
if (value instanceof String) |
||||
|
{ |
||||
|
return (String) value; |
||||
|
} |
||||
|
return value.toString(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为字符串<br> |
||||
|
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br> |
||||
|
* 转换失败不会报错 |
||||
|
* |
||||
|
* @param value 被转换的值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static String toStr(Object value) |
||||
|
{ |
||||
|
return toStr(value, null); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为字符<br> |
||||
|
* 如果给定的值为null,或者转换失败,返回默认值<br> |
||||
|
* 转换失败不会报错 |
||||
|
* |
||||
|
* @param value 被转换的值 |
||||
|
* @param defaultValue 转换错误时的默认值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static Character toChar(Object value, Character defaultValue) |
||||
|
{ |
||||
|
if (null == value) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
if (value instanceof Character) |
||||
|
{ |
||||
|
return (Character) value; |
||||
|
} |
||||
|
|
||||
|
final String valueStr = toStr(value, null); |
||||
|
return StringUtils.isEmpty(valueStr) ? defaultValue : valueStr.charAt(0); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为字符<br> |
||||
|
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br> |
||||
|
* 转换失败不会报错 |
||||
|
* |
||||
|
* @param value 被转换的值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static Character toChar(Object value) |
||||
|
{ |
||||
|
return toChar(value, null); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为byte<br> |
||||
|
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br> |
||||
|
* 转换失败不会报错 |
||||
|
* |
||||
|
* @param value 被转换的值 |
||||
|
* @param defaultValue 转换错误时的默认值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static Byte toByte(Object value, Byte defaultValue) |
||||
|
{ |
||||
|
if (value == null) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
if (value instanceof Byte) |
||||
|
{ |
||||
|
return (Byte) value; |
||||
|
} |
||||
|
if (value instanceof Number) |
||||
|
{ |
||||
|
return ((Number) value).byteValue(); |
||||
|
} |
||||
|
final String valueStr = toStr(value, null); |
||||
|
if (StringUtils.isEmpty(valueStr)) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
try |
||||
|
{ |
||||
|
return Byte.parseByte(valueStr); |
||||
|
} |
||||
|
catch (Exception e) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为byte<br> |
||||
|
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br> |
||||
|
* 转换失败不会报错 |
||||
|
* |
||||
|
* @param value 被转换的值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static Byte toByte(Object value) |
||||
|
{ |
||||
|
return toByte(value, null); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为Short<br> |
||||
|
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br> |
||||
|
* 转换失败不会报错 |
||||
|
* |
||||
|
* @param value 被转换的值 |
||||
|
* @param defaultValue 转换错误时的默认值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static Short toShort(Object value, Short defaultValue) |
||||
|
{ |
||||
|
if (value == null) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
if (value instanceof Short) |
||||
|
{ |
||||
|
return (Short) value; |
||||
|
} |
||||
|
if (value instanceof Number) |
||||
|
{ |
||||
|
return ((Number) value).shortValue(); |
||||
|
} |
||||
|
final String valueStr = toStr(value, null); |
||||
|
if (StringUtils.isEmpty(valueStr)) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
try |
||||
|
{ |
||||
|
return Short.parseShort(valueStr.trim()); |
||||
|
} |
||||
|
catch (Exception e) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为Short<br> |
||||
|
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br> |
||||
|
* 转换失败不会报错 |
||||
|
* |
||||
|
* @param value 被转换的值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static Short toShort(Object value) |
||||
|
{ |
||||
|
return toShort(value, null); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为Number<br> |
||||
|
* 如果给定的值为空,或者转换失败,返回默认值<br> |
||||
|
* 转换失败不会报错 |
||||
|
* |
||||
|
* @param value 被转换的值 |
||||
|
* @param defaultValue 转换错误时的默认值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static Number toNumber(Object value, Number defaultValue) |
||||
|
{ |
||||
|
if (value == null) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
if (value instanceof Number) |
||||
|
{ |
||||
|
return (Number) value; |
||||
|
} |
||||
|
final String valueStr = toStr(value, null); |
||||
|
if (StringUtils.isEmpty(valueStr)) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
try |
||||
|
{ |
||||
|
return NumberFormat.getInstance().parse(valueStr); |
||||
|
} |
||||
|
catch (Exception e) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为Number<br> |
||||
|
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br> |
||||
|
* 转换失败不会报错 |
||||
|
* |
||||
|
* @param value 被转换的值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static Number toNumber(Object value) |
||||
|
{ |
||||
|
return toNumber(value, null); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为int<br> |
||||
|
* 如果给定的值为空,或者转换失败,返回默认值<br> |
||||
|
* 转换失败不会报错 |
||||
|
* |
||||
|
* @param value 被转换的值 |
||||
|
* @param defaultValue 转换错误时的默认值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static Integer toInt(Object value, Integer defaultValue) |
||||
|
{ |
||||
|
if (value == null) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
if (value instanceof Integer) |
||||
|
{ |
||||
|
return (Integer) value; |
||||
|
} |
||||
|
if (value instanceof Number) |
||||
|
{ |
||||
|
return ((Number) value).intValue(); |
||||
|
} |
||||
|
final String valueStr = toStr(value, null); |
||||
|
if (StringUtils.isEmpty(valueStr)) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
try |
||||
|
{ |
||||
|
return Integer.parseInt(valueStr.trim()); |
||||
|
} |
||||
|
catch (Exception e) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为int<br> |
||||
|
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br> |
||||
|
* 转换失败不会报错 |
||||
|
* |
||||
|
* @param value 被转换的值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static Integer toInt(Object value) |
||||
|
{ |
||||
|
return toInt(value, null); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为Integer数组<br> |
||||
|
* |
||||
|
* @param str 被转换的值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static Integer[] toIntArray(String str) |
||||
|
{ |
||||
|
return toIntArray(",", str); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为Long数组<br> |
||||
|
* |
||||
|
* @param str 被转换的值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static Long[] toLongArray(String str) |
||||
|
{ |
||||
|
return toLongArray(",", str); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为Integer数组<br> |
||||
|
* |
||||
|
* @param split 分隔符 |
||||
|
* @param split 被转换的值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static Integer[] toIntArray(String split, String str) |
||||
|
{ |
||||
|
if (StringUtils.isEmpty(str)) |
||||
|
{ |
||||
|
return new Integer[] {}; |
||||
|
} |
||||
|
String[] arr = str.split(split); |
||||
|
final Integer[] ints = new Integer[arr.length]; |
||||
|
for (int i = 0; i < arr.length; i++) |
||||
|
{ |
||||
|
final Integer v = toInt(arr[i], 0); |
||||
|
ints[i] = v; |
||||
|
} |
||||
|
return ints; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为Long数组<br> |
||||
|
* |
||||
|
* @param split 分隔符 |
||||
|
* @param str 被转换的值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static Long[] toLongArray(String split, String str) |
||||
|
{ |
||||
|
if (StringUtils.isEmpty(str)) |
||||
|
{ |
||||
|
return new Long[] {}; |
||||
|
} |
||||
|
String[] arr = str.split(split); |
||||
|
final Long[] longs = new Long[arr.length]; |
||||
|
for (int i = 0; i < arr.length; i++) |
||||
|
{ |
||||
|
final Long v = toLong(arr[i], null); |
||||
|
longs[i] = v; |
||||
|
} |
||||
|
return longs; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为String数组<br> |
||||
|
* |
||||
|
* @param str 被转换的值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static String[] toStrArray(String str) |
||||
|
{ |
||||
|
return toStrArray(",", str); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为String数组<br> |
||||
|
* |
||||
|
* @param split 分隔符 |
||||
|
* @param split 被转换的值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static String[] toStrArray(String split, String str) |
||||
|
{ |
||||
|
return str.split(split); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为long<br> |
||||
|
* 如果给定的值为空,或者转换失败,返回默认值<br> |
||||
|
* 转换失败不会报错 |
||||
|
* |
||||
|
* @param value 被转换的值 |
||||
|
* @param defaultValue 转换错误时的默认值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static Long toLong(Object value, Long defaultValue) |
||||
|
{ |
||||
|
if (value == null) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
if (value instanceof Long) |
||||
|
{ |
||||
|
return (Long) value; |
||||
|
} |
||||
|
if (value instanceof Number) |
||||
|
{ |
||||
|
return ((Number) value).longValue(); |
||||
|
} |
||||
|
final String valueStr = toStr(value, null); |
||||
|
if (StringUtils.isEmpty(valueStr)) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
try |
||||
|
{ |
||||
|
// 支持科学计数法
|
||||
|
return new BigDecimal(valueStr.trim()).longValue(); |
||||
|
} |
||||
|
catch (Exception e) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为long<br> |
||||
|
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br> |
||||
|
* 转换失败不会报错 |
||||
|
* |
||||
|
* @param value 被转换的值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static Long toLong(Object value) |
||||
|
{ |
||||
|
return toLong(value, null); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为double<br> |
||||
|
* 如果给定的值为空,或者转换失败,返回默认值<br> |
||||
|
* 转换失败不会报错 |
||||
|
* |
||||
|
* @param value 被转换的值 |
||||
|
* @param defaultValue 转换错误时的默认值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static Double toDouble(Object value, Double defaultValue) |
||||
|
{ |
||||
|
if (value == null) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
if (value instanceof Double) |
||||
|
{ |
||||
|
return (Double) value; |
||||
|
} |
||||
|
if (value instanceof Number) |
||||
|
{ |
||||
|
return ((Number) value).doubleValue(); |
||||
|
} |
||||
|
final String valueStr = toStr(value, null); |
||||
|
if (StringUtils.isEmpty(valueStr)) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
try |
||||
|
{ |
||||
|
// 支持科学计数法
|
||||
|
return new BigDecimal(valueStr.trim()).doubleValue(); |
||||
|
} |
||||
|
catch (Exception e) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为double<br> |
||||
|
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br> |
||||
|
* 转换失败不会报错 |
||||
|
* |
||||
|
* @param value 被转换的值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static Double toDouble(Object value) |
||||
|
{ |
||||
|
return toDouble(value, null); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为Float<br> |
||||
|
* 如果给定的值为空,或者转换失败,返回默认值<br> |
||||
|
* 转换失败不会报错 |
||||
|
* |
||||
|
* @param value 被转换的值 |
||||
|
* @param defaultValue 转换错误时的默认值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static Float toFloat(Object value, Float defaultValue) |
||||
|
{ |
||||
|
if (value == null) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
if (value instanceof Float) |
||||
|
{ |
||||
|
return (Float) value; |
||||
|
} |
||||
|
if (value instanceof Number) |
||||
|
{ |
||||
|
return ((Number) value).floatValue(); |
||||
|
} |
||||
|
final String valueStr = toStr(value, null); |
||||
|
if (StringUtils.isEmpty(valueStr)) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
try |
||||
|
{ |
||||
|
return Float.parseFloat(valueStr.trim()); |
||||
|
} |
||||
|
catch (Exception e) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为Float<br> |
||||
|
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br> |
||||
|
* 转换失败不会报错 |
||||
|
* |
||||
|
* @param value 被转换的值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static Float toFloat(Object value) |
||||
|
{ |
||||
|
return toFloat(value, null); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为boolean<br> |
||||
|
* String支持的值为:true、false、yes、ok、no,1,0 如果给定的值为空,或者转换失败,返回默认值<br> |
||||
|
* 转换失败不会报错 |
||||
|
* |
||||
|
* @param value 被转换的值 |
||||
|
* @param defaultValue 转换错误时的默认值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static Boolean toBool(Object value, Boolean defaultValue) |
||||
|
{ |
||||
|
if (value == null) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
if (value instanceof Boolean) |
||||
|
{ |
||||
|
return (Boolean) value; |
||||
|
} |
||||
|
String valueStr = toStr(value, null); |
||||
|
if (StringUtils.isEmpty(valueStr)) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
valueStr = valueStr.trim().toLowerCase(); |
||||
|
switch (valueStr) |
||||
|
{ |
||||
|
case "true": |
||||
|
return true; |
||||
|
case "false": |
||||
|
return false; |
||||
|
case "yes": |
||||
|
return true; |
||||
|
case "ok": |
||||
|
return true; |
||||
|
case "no": |
||||
|
return false; |
||||
|
case "1": |
||||
|
return true; |
||||
|
case "0": |
||||
|
return false; |
||||
|
default: |
||||
|
return defaultValue; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为boolean<br> |
||||
|
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br> |
||||
|
* 转换失败不会报错 |
||||
|
* |
||||
|
* @param value 被转换的值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static Boolean toBool(Object value) |
||||
|
{ |
||||
|
return toBool(value, null); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为Enum对象<br> |
||||
|
* 如果给定的值为空,或者转换失败,返回默认值<br> |
||||
|
* |
||||
|
* @param clazz Enum的Class |
||||
|
* @param value 值 |
||||
|
* @param defaultValue 默认值 |
||||
|
* @return Enum |
||||
|
*/ |
||||
|
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value, E defaultValue) |
||||
|
{ |
||||
|
if (value == null) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
if (clazz.isAssignableFrom(value.getClass())) |
||||
|
{ |
||||
|
@SuppressWarnings("unchecked") |
||||
|
E myE = (E) value; |
||||
|
return myE; |
||||
|
} |
||||
|
final String valueStr = toStr(value, null); |
||||
|
if (StringUtils.isEmpty(valueStr)) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
try |
||||
|
{ |
||||
|
return Enum.valueOf(clazz, valueStr); |
||||
|
} |
||||
|
catch (Exception e) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为Enum对象<br> |
||||
|
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br> |
||||
|
* |
||||
|
* @param clazz Enum的Class |
||||
|
* @param value 值 |
||||
|
* @return Enum |
||||
|
*/ |
||||
|
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value) |
||||
|
{ |
||||
|
return toEnum(clazz, value, null); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为BigInteger<br> |
||||
|
* 如果给定的值为空,或者转换失败,返回默认值<br> |
||||
|
* 转换失败不会报错 |
||||
|
* |
||||
|
* @param value 被转换的值 |
||||
|
* @param defaultValue 转换错误时的默认值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static BigInteger toBigInteger(Object value, BigInteger defaultValue) |
||||
|
{ |
||||
|
if (value == null) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
if (value instanceof BigInteger) |
||||
|
{ |
||||
|
return (BigInteger) value; |
||||
|
} |
||||
|
if (value instanceof Long) |
||||
|
{ |
||||
|
return BigInteger.valueOf((Long) value); |
||||
|
} |
||||
|
final String valueStr = toStr(value, null); |
||||
|
if (StringUtils.isEmpty(valueStr)) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
try |
||||
|
{ |
||||
|
return new BigInteger(valueStr); |
||||
|
} |
||||
|
catch (Exception e) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为BigInteger<br> |
||||
|
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br> |
||||
|
* 转换失败不会报错 |
||||
|
* |
||||
|
* @param value 被转换的值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static BigInteger toBigInteger(Object value) |
||||
|
{ |
||||
|
return toBigInteger(value, null); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为BigDecimal<br> |
||||
|
* 如果给定的值为空,或者转换失败,返回默认值<br> |
||||
|
* 转换失败不会报错 |
||||
|
* |
||||
|
* @param value 被转换的值 |
||||
|
* @param defaultValue 转换错误时的默认值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue) |
||||
|
{ |
||||
|
if (value == null) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
if (value instanceof BigDecimal) |
||||
|
{ |
||||
|
return (BigDecimal) value; |
||||
|
} |
||||
|
if (value instanceof Long) |
||||
|
{ |
||||
|
return new BigDecimal((Long) value); |
||||
|
} |
||||
|
if (value instanceof Double) |
||||
|
{ |
||||
|
return new BigDecimal((Double) value); |
||||
|
} |
||||
|
if (value instanceof Integer) |
||||
|
{ |
||||
|
return new BigDecimal((Integer) value); |
||||
|
} |
||||
|
final String valueStr = toStr(value, null); |
||||
|
if (StringUtils.isEmpty(valueStr)) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
try |
||||
|
{ |
||||
|
return new BigDecimal(valueStr); |
||||
|
} |
||||
|
catch (Exception e) |
||||
|
{ |
||||
|
return defaultValue; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换为BigDecimal<br> |
||||
|
* 如果给定的值为空,或者转换失败,返回默认值<br> |
||||
|
* 转换失败不会报错 |
||||
|
* |
||||
|
* @param value 被转换的值 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static BigDecimal toBigDecimal(Object value) |
||||
|
{ |
||||
|
return toBigDecimal(value, null); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 将对象转为字符串<br> |
||||
|
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 |
||||
|
* |
||||
|
* @param obj 对象 |
||||
|
* @return 字符串 |
||||
|
*/ |
||||
|
public static String utf8Str(Object obj) |
||||
|
{ |
||||
|
return str(obj, CharsetKit.CHARSET_UTF_8); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 将对象转为字符串<br> |
||||
|
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 |
||||
|
* |
||||
|
* @param obj 对象 |
||||
|
* @param charsetName 字符集 |
||||
|
* @return 字符串 |
||||
|
*/ |
||||
|
public static String str(Object obj, String charsetName) |
||||
|
{ |
||||
|
return str(obj, Charset.forName(charsetName)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 将对象转为字符串<br> |
||||
|
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 |
||||
|
* |
||||
|
* @param obj 对象 |
||||
|
* @param charset 字符集 |
||||
|
* @return 字符串 |
||||
|
*/ |
||||
|
public static String str(Object obj, Charset charset) |
||||
|
{ |
||||
|
if (null == obj) |
||||
|
{ |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
if (obj instanceof String) |
||||
|
{ |
||||
|
return (String) obj; |
||||
|
} |
||||
|
else if (obj instanceof byte[] || obj instanceof Byte[]) |
||||
|
{ |
||||
|
return str((Byte[]) obj, charset); |
||||
|
} |
||||
|
else if (obj instanceof ByteBuffer) |
||||
|
{ |
||||
|
return str((ByteBuffer) obj, charset); |
||||
|
} |
||||
|
return obj.toString(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 将byte数组转为字符串 |
||||
|
* |
||||
|
* @param bytes byte数组 |
||||
|
* @param charset 字符集 |
||||
|
* @return 字符串 |
||||
|
*/ |
||||
|
public static String str(byte[] bytes, String charset) |
||||
|
{ |
||||
|
return str(bytes, StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 解码字节码 |
||||
|
* |
||||
|
* @param data 字符串 |
||||
|
* @param charset 字符集,如果此字段为空,则解码的结果取决于平台 |
||||
|
* @return 解码后的字符串 |
||||
|
*/ |
||||
|
public static String str(byte[] data, Charset charset) |
||||
|
{ |
||||
|
if (data == null) |
||||
|
{ |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
if (null == charset) |
||||
|
{ |
||||
|
return new String(data); |
||||
|
} |
||||
|
return new String(data, charset); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 将编码的byteBuffer数据转换为字符串 |
||||
|
* |
||||
|
* @param data 数据 |
||||
|
* @param charset 字符集,如果为空使用当前系统字符集 |
||||
|
* @return 字符串 |
||||
|
*/ |
||||
|
public static String str(ByteBuffer data, String charset) |
||||
|
{ |
||||
|
if (data == null) |
||||
|
{ |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
return str(data, Charset.forName(charset)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 将编码的byteBuffer数据转换为字符串 |
||||
|
* |
||||
|
* @param data 数据 |
||||
|
* @param charset 字符集,如果为空使用当前系统字符集 |
||||
|
* @return 字符串 |
||||
|
*/ |
||||
|
public static String str(ByteBuffer data, Charset charset) |
||||
|
{ |
||||
|
if (null == charset) |
||||
|
{ |
||||
|
charset = Charset.defaultCharset(); |
||||
|
} |
||||
|
return charset.decode(data).toString(); |
||||
|
} |
||||
|
|
||||
|
// ----------------------------------------------------------------------- 全角半角转换
|
||||
|
/** |
||||
|
* 半角转全角 |
||||
|
* |
||||
|
* @param input String. |
||||
|
* @return 全角字符串. |
||||
|
*/ |
||||
|
public static String toSBC(String input) |
||||
|
{ |
||||
|
return toSBC(input, null); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 半角转全角 |
||||
|
* |
||||
|
* @param input String |
||||
|
* @param notConvertSet 不替换的字符集合 |
||||
|
* @return 全角字符串. |
||||
|
*/ |
||||
|
public static String toSBC(String input, Set<Character> notConvertSet) |
||||
|
{ |
||||
|
char c[] = input.toCharArray(); |
||||
|
for (int i = 0; i < c.length; i++) |
||||
|
{ |
||||
|
if (null != notConvertSet && notConvertSet.contains(c[i])) |
||||
|
{ |
||||
|
// 跳过不替换的字符
|
||||
|
continue; |
||||
|
} |
||||
|
|
||||
|
if (c[i] == ' ') |
||||
|
{ |
||||
|
c[i] = '\u3000'; |
||||
|
} |
||||
|
else if (c[i] < '\177') |
||||
|
{ |
||||
|
c[i] = (char) (c[i] + 65248); |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
return new String(c); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 全角转半角 |
||||
|
* |
||||
|
* @param input String. |
||||
|
* @return 半角字符串 |
||||
|
*/ |
||||
|
public static String toDBC(String input) |
||||
|
{ |
||||
|
return toDBC(input, null); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 替换全角为半角 |
||||
|
* |
||||
|
* @param text 文本 |
||||
|
* @param notConvertSet 不替换的字符集合 |
||||
|
* @return 替换后的字符 |
||||
|
*/ |
||||
|
public static String toDBC(String text, Set<Character> notConvertSet) |
||||
|
{ |
||||
|
char c[] = text.toCharArray(); |
||||
|
for (int i = 0; i < c.length; i++) |
||||
|
{ |
||||
|
if (null != notConvertSet && notConvertSet.contains(c[i])) |
||||
|
{ |
||||
|
// 跳过不替换的字符
|
||||
|
continue; |
||||
|
} |
||||
|
|
||||
|
if (c[i] == '\u3000') |
||||
|
{ |
||||
|
c[i] = ' '; |
||||
|
} |
||||
|
else if (c[i] > '\uFF00' && c[i] < '\uFF5F') |
||||
|
{ |
||||
|
c[i] = (char) (c[i] - 65248); |
||||
|
} |
||||
|
} |
||||
|
String returnString = new String(c); |
||||
|
|
||||
|
return returnString; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 数字金额大写转换 先写个完整的然后将如零拾替换成零 |
||||
|
* |
||||
|
* @param n 数字 |
||||
|
* @return 中文大写数字 |
||||
|
*/ |
||||
|
public static String digitUppercase(double n) |
||||
|
{ |
||||
|
String[] fraction = { "角", "分" }; |
||||
|
String[] digit = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" }; |
||||
|
String[][] unit = { { "元", "万", "亿" }, { "", "拾", "佰", "仟" } }; |
||||
|
|
||||
|
String head = n < 0 ? "负" : ""; |
||||
|
n = Math.abs(n); |
||||
|
|
||||
|
String s = ""; |
||||
|
for (int i = 0; i < fraction.length; i++) |
||||
|
{ |
||||
|
s += (digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", ""); |
||||
|
} |
||||
|
if (s.length() < 1) |
||||
|
{ |
||||
|
s = "整"; |
||||
|
} |
||||
|
int integerPart = (int) Math.floor(n); |
||||
|
|
||||
|
for (int i = 0; i < unit[0].length && integerPart > 0; i++) |
||||
|
{ |
||||
|
String p = ""; |
||||
|
for (int j = 0; j < unit[1].length && n > 0; j++) |
||||
|
{ |
||||
|
p = digit[integerPart % 10] + unit[1][j] + p; |
||||
|
integerPart = integerPart / 10; |
||||
|
} |
||||
|
s = p.replaceAll("(零.)*零$", "").replaceAll("^$", "零") + unit[0][i] + s; |
||||
|
} |
||||
|
return head + s.replaceAll("(零.)*零元", "元").replaceFirst("(零.)+", "").replaceAll("(零.)+", "零").replaceAll("^整$", "零元整"); |
||||
|
} |
||||
|
} |
@ -0,0 +1,23 @@ |
|||||
|
package com.yxt.oms.utils; |
||||
|
|
||||
|
/** |
||||
|
* @author dimengzhe |
||||
|
* @date 2021/6/16 10:50 |
||||
|
* @description |
||||
|
*/ |
||||
|
|
||||
|
public class HttpStatus { |
||||
|
|
||||
|
/** |
||||
|
* 操作成功 |
||||
|
*/ |
||||
|
public static final int SUCCESS = 200; |
||||
|
|
||||
|
/** |
||||
|
* 系统内部错误 |
||||
|
*/ |
||||
|
public static final int ERROR = 500; |
||||
|
|
||||
|
public static final String OVERDUE = "5000"; |
||||
|
|
||||
|
} |
@ -0,0 +1,167 @@ |
|||||
|
package com.yxt.oms.utils; |
||||
|
|
||||
|
import org.apache.http.Consts; |
||||
|
import org.apache.http.HttpEntity; |
||||
|
import org.apache.http.NameValuePair; |
||||
|
import org.apache.http.client.entity.UrlEncodedFormEntity; |
||||
|
import org.apache.http.client.methods.CloseableHttpResponse; |
||||
|
import org.apache.http.client.methods.HttpGet; |
||||
|
import org.apache.http.client.methods.HttpPost; |
||||
|
import org.apache.http.entity.StringEntity; |
||||
|
import org.apache.http.impl.client.CloseableHttpClient; |
||||
|
import org.apache.http.impl.client.HttpClients; |
||||
|
import org.apache.http.message.BasicNameValuePair; |
||||
|
import org.apache.http.util.EntityUtils; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
|
||||
|
import java.io.IOException; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
public class HttpUtils { |
||||
|
private static final Logger log = LoggerFactory.getLogger(HttpUtils.class); |
||||
|
private static final CloseableHttpClient httpclient = HttpClients.createDefault(); |
||||
|
private static final String userAgent = "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.87 Safari/537.36"; |
||||
|
|
||||
|
/** |
||||
|
* 发送HttpGet请求 * * @param url * 请求地址 * @return 返回字符串 |
||||
|
*/ |
||||
|
public static String sendGet(String url, String token) { |
||||
|
String result = null; |
||||
|
CloseableHttpResponse response = null; |
||||
|
try { |
||||
|
HttpGet httpGet = new HttpGet(url); |
||||
|
httpGet.setHeader("User-Agent", userAgent); |
||||
|
httpGet.setHeader("Authorization", "token " + token); |
||||
|
response = httpclient.execute(httpGet); |
||||
|
HttpEntity entity = response.getEntity(); |
||||
|
if (entity != null) { |
||||
|
result = EntityUtils.toString(entity); |
||||
|
} |
||||
|
} catch (Exception e) { |
||||
|
log.error("处理失败 {}" + e); |
||||
|
e.printStackTrace(); |
||||
|
} finally { |
||||
|
if (response != null) { |
||||
|
try { |
||||
|
response.close(); |
||||
|
} catch (IOException e) { |
||||
|
log.error(e.getMessage()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 发送HttpPost请求,参数为map * * @param url * 请求地址 * @param map * 请求参数 * @return 返回字符串 |
||||
|
*/ |
||||
|
public static String sendPost(String url, Map<String, String> map) { |
||||
|
// 设置参数
|
||||
|
List<NameValuePair> formparams = new ArrayList<NameValuePair>(); |
||||
|
for (Map.Entry<String, String> entry : map.entrySet()) { |
||||
|
formparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); |
||||
|
} |
||||
|
// 编码
|
||||
|
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(formparams, Consts.UTF_8); |
||||
|
// 取得HttpPost对象
|
||||
|
HttpPost httpPost = new HttpPost(url); |
||||
|
// 防止被当成攻击添加的
|
||||
|
httpPost.setHeader("User-Agent", userAgent); |
||||
|
// 参数放入Entity
|
||||
|
httpPost.setEntity(formEntity); |
||||
|
CloseableHttpResponse response = null; |
||||
|
String result = null; |
||||
|
try { |
||||
|
// 执行post请求
|
||||
|
response = httpclient.execute(httpPost); |
||||
|
// 得到entity
|
||||
|
HttpEntity entity = response.getEntity(); |
||||
|
// 得到字符串
|
||||
|
result = EntityUtils.toString(entity); |
||||
|
} catch (IOException e) { |
||||
|
log.error(e.getMessage()); |
||||
|
} finally { |
||||
|
if (response != null) { |
||||
|
try { |
||||
|
response.close(); |
||||
|
} catch (IOException e) { |
||||
|
log.error(e.getMessage()); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 发送HttpPost请求,参数为json字符串 * * @param url * @param jsonStr * @return |
||||
|
*/ |
||||
|
public static String sendPost(String url, String jsonStr) { |
||||
|
String result = null; |
||||
|
// 字符串编码
|
||||
|
StringEntity entity = new StringEntity(jsonStr, Consts.UTF_8); |
||||
|
// 设置content-type
|
||||
|
entity.setContentType("application/json"); |
||||
|
HttpPost httpPost = new HttpPost(url); |
||||
|
// 防止被当成攻击添加的
|
||||
|
httpPost.setHeader("User-Agent", userAgent); |
||||
|
// 接收参数设置
|
||||
|
httpPost.setHeader("Accept", "application/json"); |
||||
|
httpPost.setEntity(entity); |
||||
|
CloseableHttpResponse response = null; |
||||
|
try { |
||||
|
response = httpclient.execute(httpPost); |
||||
|
HttpEntity httpEntity = response.getEntity(); |
||||
|
result = EntityUtils.toString(httpEntity); |
||||
|
} catch (IOException e) { |
||||
|
log.error(e.getMessage()); |
||||
|
} finally { |
||||
|
// 关闭CloseableHttpResponse
|
||||
|
if (response != null) { |
||||
|
try { |
||||
|
response.close(); |
||||
|
} catch (IOException e) { |
||||
|
log.error(e.getMessage()); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 发送不带参数的HttpPost请求 * * @param url * @return |
||||
|
*/ |
||||
|
public static String sendPost(String url) { |
||||
|
String result = null; |
||||
|
// 得到一个HttpPost对象
|
||||
|
HttpPost httpPost = new HttpPost(url); |
||||
|
// 防止被当成攻击添加的
|
||||
|
httpPost.setHeader("User-Agent", userAgent); |
||||
|
CloseableHttpResponse response = null; |
||||
|
try { |
||||
|
// 执行HttpPost请求,并得到一个CloseableHttpResponse
|
||||
|
response = httpclient.execute(httpPost); |
||||
|
// 从CloseableHttpResponse中拿到HttpEntity
|
||||
|
HttpEntity entity = response.getEntity(); |
||||
|
// 将HttpEntity转换为字符串
|
||||
|
result = EntityUtils.toString(entity); |
||||
|
} catch (IOException e) { |
||||
|
log.error(e.getMessage()); |
||||
|
} finally { |
||||
|
// 关闭CloseableHttpResponse
|
||||
|
if (response != null) { |
||||
|
try { |
||||
|
response.close(); |
||||
|
} catch (IOException e) { |
||||
|
log.error(e.getMessage()); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,44 @@ |
|||||
|
/********************************************************* |
||||
|
********************************************************* |
||||
|
******************** ******************* |
||||
|
************* ************ |
||||
|
******* _oo0oo_ ******* |
||||
|
*** o8888888o *** |
||||
|
* 88" . "88 * |
||||
|
* (| -_- |) * |
||||
|
* 0\ = /0 * |
||||
|
* ___/`---'\___ * |
||||
|
* .' \\| |// '. *
|
||||
|
* / \\||| : |||// \ *
|
||||
|
* / _||||| -:- |||||- \ * |
||||
|
* | | \\\ - /// | | *
|
||||
|
* | \_| ''\---/'' |_/ | * |
||||
|
* \ .-\__ '-' ___/-. / * |
||||
|
* ___'. .' /--.--\ `. .'___ * |
||||
|
* ."" '< `.___\_<|>_/___.' >' "". * |
||||
|
* | | : `- \`.;`\ _ /`;.`/ - ` : | | * |
||||
|
* \ \ `_. \_ __\ /__ _/ .-` / / * |
||||
|
* =====`-.____`.___ \_____/___.-`___.-'===== * |
||||
|
* `=---=' * |
||||
|
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * |
||||
|
*********__佛祖保佑__永无BUG__验收通过__钞票多多__********* |
||||
|
*********************************************************/ |
||||
|
package com.yxt.oms.utils; |
||||
|
|
||||
|
/** |
||||
|
* Project: yxt-common <br/> |
||||
|
* File: IResultCodeMsg.java <br/> |
||||
|
* Class: com.yxt.common.core.result.IResultCodeMsg <br/> |
||||
|
* Description: <描述类的功能>. <br/> |
||||
|
* Copyright: Copyright (c) 2011 <br/> |
||||
|
* Company: https://gitee.com/liuzp315 <br/>
|
||||
|
* Makedate: 2021/9/11 下午11:00 <br/> |
||||
|
* |
||||
|
* @author popo |
||||
|
* @version 1.0 |
||||
|
* @since 1.0 |
||||
|
*/ |
||||
|
public interface IResultCodeMsg { |
||||
|
String getCode(); |
||||
|
String getMsg(); |
||||
|
} |
@ -0,0 +1,42 @@ |
|||||
|
package com.yxt.oms.utils; |
||||
|
|
||||
|
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
|
import org.springframework.cloud.context.config.annotation.RefreshScope; |
||||
|
import org.springframework.context.annotation.Configuration; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author dimengzhe |
||||
|
* @date 2020/12/2 9:54 |
||||
|
* @description 放行白名单配置 |
||||
|
*/ |
||||
|
@Configuration |
||||
|
@RefreshScope |
||||
|
@ConfigurationProperties(prefix = "ignore") |
||||
|
public class IgnoreWhiteProperties { |
||||
|
|
||||
|
/** |
||||
|
* 放行白名单配置,网关不校验此处的白名单 |
||||
|
*/ |
||||
|
private List<String> whites = new ArrayList<>(); |
||||
|
|
||||
|
public List<String> getWhites() { |
||||
|
return whites; |
||||
|
} |
||||
|
|
||||
|
public void setWhites(List<String> whites) { |
||||
|
this.whites = whites; |
||||
|
} |
||||
|
|
||||
|
private List<String> whitesTwo = new ArrayList<>(); |
||||
|
|
||||
|
public List<String> getWhitesTwo() { |
||||
|
return whitesTwo; |
||||
|
} |
||||
|
|
||||
|
public void setWhitesTwo(List<String> whitesTwo) { |
||||
|
this.whitesTwo = whitesTwo; |
||||
|
} |
||||
|
} |
@ -0,0 +1,191 @@ |
|||||
|
package com.yxt.oms.utils; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* Project: yxt-common-core <br/> |
||||
|
* File: ResultBean.java <br/> |
||||
|
* Class: com.yxt.common.core.result.ResultBean <br/> |
||||
|
* Description: 通过接口、Rest、逻辑处理执行后的结果信息. <br/> |
||||
|
* Copyright: Copyright (c) 2011 <br/> |
||||
|
* Company: https://gitee.com/liuzp315 <br/>
|
||||
|
* Makedate: 2020/8/4 0:51 <br/> |
||||
|
* |
||||
|
* @author liupopo |
||||
|
* @version 1.0 |
||||
|
* @since 1.0 |
||||
|
*/ |
||||
|
public class ResultBean<T> implements Serializable { |
||||
|
private static final long serialVersionUID = 4529658978692424234L; |
||||
|
|
||||
|
private long timestamp = System.currentTimeMillis(); |
||||
|
|
||||
|
public long getTimestamp() { |
||||
|
return timestamp; |
||||
|
} |
||||
|
|
||||
|
// 是否成功
|
||||
|
private boolean success; |
||||
|
|
||||
|
// 消息 返回结果的说明
|
||||
|
private String msg; |
||||
|
|
||||
|
// 结果状态码
|
||||
|
private String code; |
||||
|
|
||||
|
// 数据
|
||||
|
private T data; |
||||
|
|
||||
|
private String message; |
||||
|
|
||||
|
public String getMessage() { |
||||
|
return message; |
||||
|
} |
||||
|
|
||||
|
public ResultBean<T> setMessage(String message) { |
||||
|
this.message = message; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public ResultBean() { |
||||
|
} |
||||
|
|
||||
|
public ResultBean(boolean success) { |
||||
|
this.success = success; |
||||
|
} |
||||
|
|
||||
|
public ResultBean(boolean success, String msg) { |
||||
|
this.success = success; |
||||
|
this.msg = msg; |
||||
|
} |
||||
|
|
||||
|
public ResultBean(boolean success, String msg, String code) { |
||||
|
this.success = success; |
||||
|
this.msg = msg; |
||||
|
this.code = code; |
||||
|
} |
||||
|
|
||||
|
public ResultBean(T data) { |
||||
|
this.success = true; |
||||
|
this.data = data; |
||||
|
} |
||||
|
|
||||
|
public ResultBean(String code, T data) { |
||||
|
this.success = true; |
||||
|
this.code = code; |
||||
|
this.data = data; |
||||
|
} |
||||
|
|
||||
|
public ResultBean(String code, String msg, T data) { |
||||
|
this.success = true; |
||||
|
this.code = code; |
||||
|
this.msg = msg; |
||||
|
this.data = data; |
||||
|
} |
||||
|
|
||||
|
public boolean getSuccess() { |
||||
|
return success; |
||||
|
} |
||||
|
|
||||
|
public ResultBean<T> setSuccess(boolean success) { |
||||
|
this.success = success; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public String getMsg() { |
||||
|
return msg; |
||||
|
} |
||||
|
|
||||
|
public ResultBean<T> setMsg(String msg) { |
||||
|
this.msg = msg; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public String getCode() { |
||||
|
return code; |
||||
|
} |
||||
|
|
||||
|
public ResultBean<T> setCode(String code) { |
||||
|
this.code = code; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public T getData() { |
||||
|
return data; |
||||
|
} |
||||
|
|
||||
|
public ResultBean<T> setData(T data) { |
||||
|
this.data = data; |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public ResultBean<T> successOne() { |
||||
|
this.setSuccess(true); |
||||
|
this.setCode("0"); |
||||
|
this.setMessage("成功!"); |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public ResultBean<T> failOne() { |
||||
|
this.setSuccess(false); |
||||
|
this.setCode(String.valueOf(HttpStatus.ERROR)); |
||||
|
this.setMessage("操作失败!"); |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public ResultBean<T> success() { |
||||
|
this.setSuccess(true); |
||||
|
this.setCode(String.valueOf(HttpStatus.SUCCESS)); |
||||
|
this.setMsg("操作成功!"); |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public ResultBean<T> fail() { |
||||
|
this.setSuccess(false); |
||||
|
this.setCode(String.valueOf(HttpStatus.ERROR)); |
||||
|
this.setMsg("操作失败!"); |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
public static <T> ResultBean<T> fireSuccess() { |
||||
|
ResultBean<T> rb = new ResultBean<T>(); |
||||
|
rb.setSuccess(true); |
||||
|
rb.setCode(String.valueOf(HttpStatus.SUCCESS)); |
||||
|
rb.setMsg("操作成功!"); |
||||
|
return rb; |
||||
|
} |
||||
|
|
||||
|
public static <T> ResultBean<T> fireFail() { |
||||
|
ResultBean<T> rb = new ResultBean<T>(); |
||||
|
rb.setSuccess(false); |
||||
|
rb.setCode(String.valueOf(HttpStatus.ERROR)); |
||||
|
rb.setMsg("操作失败!"); |
||||
|
return rb; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 设置返回code及msg |
||||
|
* |
||||
|
* @param codeMsg Code和Msg的枚举 |
||||
|
* @return |
||||
|
*/ |
||||
|
public ResultBean<T> setCode(IResultCodeMsg codeMsg) { |
||||
|
this.code = codeMsg.getCode(); |
||||
|
this.msg = codeMsg.getMsg(); |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 返回失败信息,并指定结果code |
||||
|
* |
||||
|
* @param codeMsg Code和Msg的枚举 |
||||
|
* @return |
||||
|
*/ |
||||
|
public ResultBean<T> fail(IResultCodeMsg codeMsg) { |
||||
|
this.setSuccess(false); |
||||
|
this.code = codeMsg.getCode(); |
||||
|
this.msg = codeMsg.getMsg(); |
||||
|
return this; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,91 @@ |
|||||
|
package com.yxt.oms.utils; |
||||
|
|
||||
|
/** |
||||
|
* @author dimengzhe |
||||
|
* @date 2020/12/2 10:00 |
||||
|
* @description |
||||
|
*/ |
||||
|
|
||||
|
public class StrFormatter { |
||||
|
|
||||
|
public static final String EMPTY_JSON = "{}"; |
||||
|
public static final char C_BACKSLASH = '\\'; |
||||
|
public static final char C_DELIM_START = '{'; |
||||
|
public static final char C_DELIM_END = '}'; |
||||
|
|
||||
|
/** |
||||
|
* 格式化字符串<br> |
||||
|
* 此方法只是简单将占位符 {} 按照顺序替换为参数<br> |
||||
|
* 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可<br> |
||||
|
* 例:<br> |
||||
|
* 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br> |
||||
|
* 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a<br> |
||||
|
* 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br> |
||||
|
* |
||||
|
* @param strPattern 字符串模板 |
||||
|
* @param argArray 参数列表 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static String format(final String strPattern, final Object... argArray) |
||||
|
{ |
||||
|
if (StringUtils.isEmpty(strPattern) || StringUtils.isEmpty(argArray)) |
||||
|
{ |
||||
|
return strPattern; |
||||
|
} |
||||
|
final int strPatternLength = strPattern.length(); |
||||
|
|
||||
|
// 初始化定义好的长度以获得更好的性能
|
||||
|
StringBuilder sbuf = new StringBuilder(strPatternLength + 50); |
||||
|
|
||||
|
int handledPosition = 0; |
||||
|
int delimIndex;// 占位符所在位置
|
||||
|
for (int argIndex = 0; argIndex < argArray.length; argIndex++) |
||||
|
{ |
||||
|
delimIndex = strPattern.indexOf(EMPTY_JSON, handledPosition); |
||||
|
if (delimIndex == -1) |
||||
|
{ |
||||
|
if (handledPosition == 0) |
||||
|
{ |
||||
|
return strPattern; |
||||
|
} |
||||
|
else |
||||
|
{ // 字符串模板剩余部分不再包含占位符,加入剩余部分后返回结果
|
||||
|
sbuf.append(strPattern, handledPosition, strPatternLength); |
||||
|
return sbuf.toString(); |
||||
|
} |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
if (delimIndex > 0 && strPattern.charAt(delimIndex - 1) == C_BACKSLASH) |
||||
|
{ |
||||
|
if (delimIndex > 1 && strPattern.charAt(delimIndex - 2) == C_BACKSLASH) |
||||
|
{ |
||||
|
// 转义符之前还有一个转义符,占位符依旧有效
|
||||
|
sbuf.append(strPattern, handledPosition, delimIndex - 1); |
||||
|
sbuf.append(Convert.utf8Str(argArray[argIndex])); |
||||
|
handledPosition = delimIndex + 2; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
// 占位符被转义
|
||||
|
argIndex--; |
||||
|
sbuf.append(strPattern, handledPosition, delimIndex - 1); |
||||
|
sbuf.append(C_DELIM_START); |
||||
|
handledPosition = delimIndex + 1; |
||||
|
} |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
// 正常占位符
|
||||
|
sbuf.append(strPattern, handledPosition, delimIndex); |
||||
|
sbuf.append(Convert.utf8Str(argArray[argIndex])); |
||||
|
handledPosition = delimIndex + 2; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
// 加入最后一个占位符后所有的字符
|
||||
|
sbuf.append(strPattern, handledPosition, strPattern.length()); |
||||
|
|
||||
|
return sbuf.toString(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,526 @@ |
|||||
|
package com.yxt.oms.utils; |
||||
|
|
||||
|
import java.util.Collection; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* @author dimengzhe |
||||
|
* @date 2020/12/2 9:59 |
||||
|
* @description |
||||
|
*/ |
||||
|
|
||||
|
public class StringUtils extends org.apache.commons.lang3.StringUtils { |
||||
|
|
||||
|
/** |
||||
|
* 空字符串 |
||||
|
*/ |
||||
|
private static final String NULLSTR = ""; |
||||
|
|
||||
|
/** |
||||
|
* 下划线 |
||||
|
*/ |
||||
|
private static final char SEPARATOR = '_'; |
||||
|
|
||||
|
/** |
||||
|
* 星号 |
||||
|
*/ |
||||
|
private static final String START = "*"; |
||||
|
|
||||
|
/** |
||||
|
* 获取参数不为空值 |
||||
|
* |
||||
|
* @param value defaultValue 要判断的value |
||||
|
* @return value 返回值 |
||||
|
*/ |
||||
|
public static <T> T nvl(T value, T defaultValue) { |
||||
|
return value != null ? value : defaultValue; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* * 判断一个Collection是否为空, 包含List,Set,Queue |
||||
|
* |
||||
|
* @param coll 要判断的Collection |
||||
|
* @return true:为空 false:非空 |
||||
|
*/ |
||||
|
public static boolean isEmpty(Collection<?> coll) { |
||||
|
return isNull(coll) || coll.isEmpty(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* * 判断一个Collection是否非空,包含List,Set,Queue |
||||
|
* |
||||
|
* @param coll 要判断的Collection |
||||
|
* @return true:非空 false:空 |
||||
|
*/ |
||||
|
public static boolean isNotEmpty(Collection<?> coll) { |
||||
|
return !isEmpty(coll); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* * 判断一个对象数组是否为空 |
||||
|
* |
||||
|
* @param objects 要判断的对象数组 |
||||
|
* * @return true:为空 false:非空 |
||||
|
*/ |
||||
|
public static boolean isEmpty(Object[] objects) { |
||||
|
return isNull(objects) || (objects.length == 0); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* * 判断一个对象数组是否非空 |
||||
|
* |
||||
|
* @param objects 要判断的对象数组 |
||||
|
* @return true:非空 false:空 |
||||
|
*/ |
||||
|
public static boolean isNotEmpty(Object[] objects) { |
||||
|
return !isEmpty(objects); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* * 判断一个Map是否为空 |
||||
|
* |
||||
|
* @param map 要判断的Map |
||||
|
* @return true:为空 false:非空 |
||||
|
*/ |
||||
|
public static boolean isEmpty(Map<?, ?> map) { |
||||
|
return isNull(map) || map.isEmpty(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* * 判断一个Map是否为空 |
||||
|
* |
||||
|
* @param map 要判断的Map |
||||
|
* @return true:非空 false:空 |
||||
|
*/ |
||||
|
public static boolean isNotEmpty(Map<?, ?> map) { |
||||
|
return !isEmpty(map); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* * 判断一个字符串是否为空串 |
||||
|
* |
||||
|
* @param str String |
||||
|
* @return true:为空 false:非空 |
||||
|
*/ |
||||
|
public static boolean isEmpty(String str) { |
||||
|
return isNull(str) || NULLSTR.equals(str.trim()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* * 判断一个字符串是否为非空串 |
||||
|
* |
||||
|
* @param str String |
||||
|
* @return true:非空串 false:空串 |
||||
|
*/ |
||||
|
public static boolean isNotEmpty(String str) { |
||||
|
return !isEmpty(str); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* * 判断一个对象是否为空 |
||||
|
* |
||||
|
* @param object Object |
||||
|
* @return true:为空 false:非空 |
||||
|
*/ |
||||
|
public static boolean isNull(Object object) { |
||||
|
return object == null; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* * 判断一个对象是否非空 |
||||
|
* |
||||
|
* @param object Object |
||||
|
* @return true:非空 false:空 |
||||
|
*/ |
||||
|
public static boolean isNotNull(Object object) { |
||||
|
return !isNull(object); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* * 判断一个对象是否是数组类型(Java基本型别的数组) |
||||
|
* |
||||
|
* @param object 对象 |
||||
|
* @return true:是数组 false:不是数组 |
||||
|
*/ |
||||
|
public static boolean isArray(Object object) { |
||||
|
return isNotNull(object) && object.getClass().isArray(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 去空格 |
||||
|
*/ |
||||
|
public static String trim(String str) { |
||||
|
return (str == null ? "" : str.trim()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 截取字符串 |
||||
|
* |
||||
|
* @param str 字符串 |
||||
|
* @param start 开始 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static String substring(final String str, int start) { |
||||
|
if (str == null) { |
||||
|
return NULLSTR; |
||||
|
} |
||||
|
|
||||
|
if (start < 0) { |
||||
|
start = str.length() + start; |
||||
|
} |
||||
|
|
||||
|
if (start < 0) { |
||||
|
start = 0; |
||||
|
} |
||||
|
if (start > str.length()) { |
||||
|
return NULLSTR; |
||||
|
} |
||||
|
|
||||
|
return str.substring(start); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 截取字符串 |
||||
|
* |
||||
|
* @param str 字符串 |
||||
|
* @param start 开始 |
||||
|
* @param end 结束 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
public static String substring(final String str, int start, int end) { |
||||
|
if (str == null) { |
||||
|
return NULLSTR; |
||||
|
} |
||||
|
|
||||
|
if (end < 0) { |
||||
|
end = str.length() + end; |
||||
|
} |
||||
|
if (start < 0) { |
||||
|
start = str.length() + start; |
||||
|
} |
||||
|
|
||||
|
if (end > str.length()) { |
||||
|
end = str.length(); |
||||
|
} |
||||
|
|
||||
|
if (start > end) { |
||||
|
return NULLSTR; |
||||
|
} |
||||
|
|
||||
|
if (start < 0) { |
||||
|
start = 0; |
||||
|
} |
||||
|
if (end < 0) { |
||||
|
end = 0; |
||||
|
} |
||||
|
|
||||
|
return str.substring(start, end); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 格式化文本, {} 表示占位符<br> |
||||
|
* 此方法只是简单将占位符 {} 按照顺序替换为参数<br> |
||||
|
* 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可<br> |
||||
|
* 例:<br> |
||||
|
* 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br> |
||||
|
* 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a<br> |
||||
|
* 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br> |
||||
|
* |
||||
|
* @param template 文本模板,被替换的部分用 {} 表示 |
||||
|
* @param params 参数值 |
||||
|
* @return 格式化后的文本 |
||||
|
*/ |
||||
|
public static String format(String template, Object... params) { |
||||
|
if (isEmpty(params) || isEmpty(template)) { |
||||
|
return template; |
||||
|
} |
||||
|
return StrFormatter.format(template, params); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 下划线转驼峰命名 |
||||
|
*/ |
||||
|
public static String toUnderScoreCase(String str) { |
||||
|
if (str == null) { |
||||
|
return null; |
||||
|
} |
||||
|
StringBuilder sb = new StringBuilder(); |
||||
|
// 前置字符是否大写
|
||||
|
boolean preCharIsUpperCase = true; |
||||
|
// 当前字符是否大写
|
||||
|
boolean curreCharIsUpperCase = true; |
||||
|
// 下一字符是否大写
|
||||
|
boolean nexteCharIsUpperCase = true; |
||||
|
for (int i = 0; i < str.length(); i++) { |
||||
|
char c = str.charAt(i); |
||||
|
if (i > 0) { |
||||
|
preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1)); |
||||
|
} else { |
||||
|
preCharIsUpperCase = false; |
||||
|
} |
||||
|
|
||||
|
curreCharIsUpperCase = Character.isUpperCase(c); |
||||
|
|
||||
|
if (i < (str.length() - 1)) { |
||||
|
nexteCharIsUpperCase = Character.isUpperCase(str.charAt(i + 1)); |
||||
|
} |
||||
|
|
||||
|
if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase) { |
||||
|
sb.append(SEPARATOR); |
||||
|
} else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase) { |
||||
|
sb.append(SEPARATOR); |
||||
|
} |
||||
|
sb.append(Character.toLowerCase(c)); |
||||
|
} |
||||
|
|
||||
|
return sb.toString(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 是否包含字符串 |
||||
|
* |
||||
|
* @param str 验证字符串 |
||||
|
* @param strs 字符串组 |
||||
|
* @return 包含返回true |
||||
|
*/ |
||||
|
public static boolean inStringIgnoreCase(String str, String... strs) { |
||||
|
if (str != null && strs != null) { |
||||
|
for (String s : strs) { |
||||
|
if (str.equalsIgnoreCase(trim(s))) { |
||||
|
return true; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld |
||||
|
* |
||||
|
* @param name 转换前的下划线大写方式命名的字符串 |
||||
|
* @return 转换后的驼峰式命名的字符串 |
||||
|
*/ |
||||
|
public static String convertToCamelCase(String name) { |
||||
|
StringBuilder result = new StringBuilder(); |
||||
|
// 快速检查
|
||||
|
if (name == null || name.isEmpty()) { |
||||
|
// 没必要转换
|
||||
|
return ""; |
||||
|
} else if (!name.contains("_")) { |
||||
|
// 不含下划线,仅将首字母大写
|
||||
|
return name.substring(0, 1).toUpperCase() + name.substring(1); |
||||
|
} |
||||
|
// 用下划线将原始字符串分割
|
||||
|
String[] camels = name.split("_"); |
||||
|
for (String camel : camels) { |
||||
|
// 跳过原始字符串中开头、结尾的下换线或双重下划线
|
||||
|
if (camel.isEmpty()) { |
||||
|
continue; |
||||
|
} |
||||
|
// 首字母大写
|
||||
|
result.append(camel.substring(0, 1).toUpperCase()); |
||||
|
result.append(camel.substring(1).toLowerCase()); |
||||
|
} |
||||
|
return result.toString(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 驼峰式命名法 例如:user_name->userName |
||||
|
*/ |
||||
|
public static String toCamelCase(String s) { |
||||
|
if (s == null) { |
||||
|
return null; |
||||
|
} |
||||
|
s = s.toLowerCase(); |
||||
|
StringBuilder sb = new StringBuilder(s.length()); |
||||
|
boolean upperCase = false; |
||||
|
for (int i = 0; i < s.length(); i++) { |
||||
|
char c = s.charAt(i); |
||||
|
|
||||
|
if (c == SEPARATOR) { |
||||
|
upperCase = true; |
||||
|
} else if (upperCase) { |
||||
|
sb.append(Character.toUpperCase(c)); |
||||
|
upperCase = false; |
||||
|
} else { |
||||
|
sb.append(c); |
||||
|
} |
||||
|
} |
||||
|
return sb.toString(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 查找指定字符串是否匹配指定字符串列表中的任意一个字符串 |
||||
|
* |
||||
|
* @param str 指定字符串 |
||||
|
* @param strs 需要检查的字符串数组 |
||||
|
* @return 是否匹配 |
||||
|
*/ |
||||
|
public static boolean matchesTwo(String str, List<String> strs) { |
||||
|
if (isEmpty(str) || isEmpty(strs)) { |
||||
|
return false; |
||||
|
} |
||||
|
for (String testStr : strs) { |
||||
|
if (matchesTwo(str, testStr)) { |
||||
|
return true; |
||||
|
} |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
public static boolean matches(String str, List<String> strs) { |
||||
|
if (isEmpty(str) || isEmpty(strs)) { |
||||
|
return false; |
||||
|
} |
||||
|
for (String testStr : strs) { |
||||
|
if (matches(str, testStr)) { |
||||
|
return true; |
||||
|
} |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 查找指定字符串是否匹配指定字符串数组中的任意一个字符串 |
||||
|
* |
||||
|
* @param str 指定字符串 |
||||
|
* @param strs 需要检查的字符串数组 |
||||
|
* @return 是否匹配 |
||||
|
*/ |
||||
|
public static boolean matches(String str, String... strs) { |
||||
|
if (isEmpty(str) || isEmpty(strs)) { |
||||
|
return false; |
||||
|
} |
||||
|
for (String testStr : strs) { |
||||
|
if (matches(str, testStr)) { |
||||
|
return true; |
||||
|
} |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
public static boolean matches(String str, String pattern) { |
||||
|
if (isEmpty(pattern) || isEmpty(str)) { |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
pattern = pattern.replaceAll("\\s*", ""); // 替换空格
|
||||
|
int beginOffset = 0; // pattern截取开始位置
|
||||
|
int formerStarOffset = -1; // 前星号的偏移位置
|
||||
|
int latterStarOffset = -1; // 后星号的偏移位置
|
||||
|
|
||||
|
String remainingURI = str; |
||||
|
String prefixPattern = ""; |
||||
|
String suffixPattern = ""; |
||||
|
|
||||
|
boolean result = false; |
||||
|
do { |
||||
|
formerStarOffset = indexOf(pattern, START, beginOffset); |
||||
|
prefixPattern = substring(pattern, beginOffset, formerStarOffset > -1 ? formerStarOffset : pattern.length()); |
||||
|
|
||||
|
// 匹配前缀Pattern
|
||||
|
result = remainingURI.equals(prefixPattern); |
||||
|
// 已经没有星号,直接返回
|
||||
|
if (formerStarOffset == -1) { |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
// 匹配失败,直接返回
|
||||
|
if (!result){ |
||||
|
return false; |
||||
|
} |
||||
|
if (!isEmpty(prefixPattern)) { |
||||
|
remainingURI = substringAfter(str, prefixPattern); |
||||
|
} |
||||
|
|
||||
|
// 匹配后缀Pattern
|
||||
|
latterStarOffset = indexOf(pattern, START, formerStarOffset + 1); |
||||
|
suffixPattern = substring(pattern, formerStarOffset + 1, latterStarOffset > -1 ? latterStarOffset : pattern.length()); |
||||
|
|
||||
|
result = remainingURI.equals(suffixPattern); |
||||
|
// 匹配失败,直接返回
|
||||
|
if (!result){ |
||||
|
return false; |
||||
|
} |
||||
|
if (!isEmpty(suffixPattern)) { |
||||
|
remainingURI = substringAfter(str, suffixPattern); |
||||
|
} |
||||
|
|
||||
|
// 移动指针
|
||||
|
beginOffset = latterStarOffset + 1; |
||||
|
|
||||
|
} |
||||
|
while (!isEmpty(suffixPattern) && !isEmpty(remainingURI)); |
||||
|
|
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 查找指定字符串是否匹配 |
||||
|
* |
||||
|
* @param str 指定字符串 |
||||
|
* @param pattern 需要检查的字符串 |
||||
|
* @return 是否匹配 |
||||
|
*/ |
||||
|
public static boolean matchesTwo(String str, String pattern) { |
||||
|
if (isEmpty(pattern) || isEmpty(str)) { |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
pattern = pattern.replaceAll("\\s*", ""); // 替换空格
|
||||
|
int beginOffset = 0; // pattern截取开始位置
|
||||
|
int formerStarOffset = -1; // 前星号的偏移位置
|
||||
|
int latterStarOffset = -1; // 后星号的偏移位置
|
||||
|
|
||||
|
String remainingURI = str; |
||||
|
String prefixPattern = ""; |
||||
|
String suffixPattern = ""; |
||||
|
|
||||
|
boolean result = false; |
||||
|
do { |
||||
|
formerStarOffset = indexOf(pattern, START, beginOffset); |
||||
|
prefixPattern = substring(pattern, beginOffset, formerStarOffset > -1 ? formerStarOffset : pattern.length()); |
||||
|
|
||||
|
// 匹配前缀Pattern
|
||||
|
result = remainingURI.contains(prefixPattern); |
||||
|
// 已经没有星号,直接返回
|
||||
|
if (formerStarOffset == -1) { |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
// 匹配失败,直接返回
|
||||
|
if (!result){ |
||||
|
return false; |
||||
|
} |
||||
|
if (!isEmpty(prefixPattern)) { |
||||
|
remainingURI = substringAfter(str, prefixPattern); |
||||
|
} |
||||
|
|
||||
|
// 匹配后缀Pattern
|
||||
|
latterStarOffset = indexOf(pattern, START, formerStarOffset + 1); |
||||
|
suffixPattern = substring(pattern, formerStarOffset + 1, latterStarOffset > -1 ? latterStarOffset : pattern.length()); |
||||
|
|
||||
|
result = remainingURI.contains(suffixPattern); |
||||
|
// 匹配失败,直接返回
|
||||
|
if (!result){ |
||||
|
return false; |
||||
|
} |
||||
|
if (!isEmpty(suffixPattern)) { |
||||
|
remainingURI = substringAfter(str, suffixPattern); |
||||
|
} |
||||
|
|
||||
|
// 移动指针
|
||||
|
beginOffset = latterStarOffset + 1; |
||||
|
|
||||
|
} |
||||
|
while (!isEmpty(suffixPattern) && !isEmpty(remainingURI)); |
||||
|
|
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
@SuppressWarnings("unchecked") |
||||
|
public static <T> T cast(Object obj) { |
||||
|
return (T) obj; |
||||
|
} |
||||
|
} |
@ -0,0 +1,20 @@ |
|||||
|
spring: |
||||
|
resources: |
||||
|
static-locations: file:D://supervise |
||||
|
cloud: |
||||
|
nacos: |
||||
|
discovery: |
||||
|
# namespace: supervise |
||||
|
server-addr: 127.0.0.1:8848 |
||||
|
redis: |
||||
|
database: 3 # Redis数据库索引(默认为0) |
||||
|
host: 127.0.0.1 |
||||
|
jedis: |
||||
|
pool: |
||||
|
max-active: -1 #连接池最大连接数(使用负值表示没有限制) |
||||
|
max-idle: 8 #连接池中的最大空闲连接 |
||||
|
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制) |
||||
|
min-idle: 0 # 连接池中的最小空闲连接 |
||||
|
password: |
||||
|
port: 6379 |
||||
|
timeout: 0 # 连接超时时间(毫秒) |
@ -0,0 +1,20 @@ |
|||||
|
spring: |
||||
|
resources: |
||||
|
static-locations: file:D://supervise |
||||
|
cloud: |
||||
|
nacos: |
||||
|
discovery: |
||||
|
# namespace: supervise |
||||
|
server-addr: 127.0.0.1:8848 |
||||
|
redis: |
||||
|
database: 3 # Redis数据库索引(默认为0) |
||||
|
host: 127.0.0.1 |
||||
|
jedis: |
||||
|
pool: |
||||
|
max-active: -1 #连接池最大连接数(使用负值表示没有限制) |
||||
|
max-idle: 8 #连接池中的最大空闲连接 |
||||
|
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制) |
||||
|
min-idle: 0 # 连接池中的最小空闲连接 |
||||
|
password: 123456 |
||||
|
port: 6379 |
||||
|
timeout: 0 # 连接超时时间(毫秒) |
@ -0,0 +1 @@ |
|||||
|
|
@ -0,0 +1,41 @@ |
|||||
|
hystrix: |
||||
|
command: |
||||
|
default: |
||||
|
execution: |
||||
|
isolation: |
||||
|
strategy: SEMAPHORE |
||||
|
thread: |
||||
|
timeoutInMilliseconds: 300000 |
||||
|
server: |
||||
|
port: 8113 |
||||
|
spring: |
||||
|
application: |
||||
|
name: gateway |
||||
|
profiles: |
||||
|
active: dev |
||||
|
# active: pro |
||||
|
cloud: |
||||
|
gateway: |
||||
|
routes: |
||||
|
- id: oms-biz |
||||
|
predicates: |
||||
|
- Path= /oms/** |
||||
|
uri: lb://oms-biz |
||||
|
filters: |
||||
|
- StripPrefix=1 |
||||
|
|
||||
|
ignore: |
||||
|
whites: |
||||
|
- /wms/apiadmin/sysuser/login #pc端登录 |
||||
|
- /wms/apiadmin/sysuser/register #pc端登录 |
||||
|
- /wms/apiadmin/sysuser/sendMessageCode/** #发送验证码 |
||||
|
- /wms/apiadmin/sysuser/sendMessageLogin/** #发送验证码 |
||||
|
- /wms/apiadmin/sysuser/sendMessageUpdate/** #发送验证码 |
||||
|
- /wms/apiadmin/sysuser/bindOrganization #绑定组织 |
||||
|
- /wms/apiadmin/sysuser/selOrganization #绑定组织 |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
whitesTwo: #包含所有 |
||||
|
- /upload/** |
@ -0,0 +1,34 @@ |
|||||
|
|
||||
|
## 商享通WMS项目结构 |
||||
|
### 一、目录说明 |
||||
|
``` |
||||
|
wms-biz -- 根项目 |
||||
|
├─ src -- 微服务的基础设施中心 |
||||
|
├─ main |
||||
|
├─ java |
||||
|
├─ com.yxt.oms |
||||
|
├─ apiadmin -- pc端后台接口路径 |
||||
|
├─ aggregation -- 多表或功能的聚合服务接口 |
||||
|
├─ apiwx -- 微信端接口路径 |
||||
|
├─ biz -- 服务类目录,一个表一个服务 |
||||
|
├─ aggregation -- 多表组合或功能的聚合服务类 |
||||
|
├─ goods -- 商品 |
||||
|
├─ inventory -- 库存 |
||||
|
├─ supplier -- 供应商 |
||||
|
├─ user -- 用户 |
||||
|
├─ warehouseout -- 出库 |
||||
|
├─ warehousereceipt -- 入库 |
||||
|
├─ warehouseset -- 仓库设置 |
||||
|
├─ config -- |
||||
|
├─ feign -- |
||||
|
├─ utils -- |
||||
|
├─ resources -- |
||||
|
|
||||
|
``` |
||||
|
### 二、项目用到的组件 |
||||
|
``` |
||||
|
1、nacos |
||||
|
2、redis |
||||
|
3、mysql |
||||
|
4、gateway |
||||
|
``` |
@ -0,0 +1,168 @@ |
|||||
|
<?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>oms-biz</artifactId> |
||||
|
<groupId>com.yxt</groupId> |
||||
|
<version>1.0-SNAPSHOT</version> |
||||
|
</parent> |
||||
|
<modelVersion>4.0.0</modelVersion> |
||||
|
|
||||
|
<groupId>com.yxt.oms</groupId> |
||||
|
<artifactId>oms</artifactId> |
||||
|
|
||||
|
<properties> |
||||
|
<maven.compiler.source>8</maven.compiler.source> |
||||
|
<maven.compiler.target>8</maven.compiler.target> |
||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
||||
|
</properties> |
||||
|
<dependencies> |
||||
|
<dependency> |
||||
|
<groupId>com.alibaba</groupId> |
||||
|
<artifactId>easyexcel</artifactId> |
||||
|
<version>3.3.2</version> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>com.yxt</groupId> |
||||
|
<artifactId>yxt-common-base</artifactId> |
||||
|
<version>0.0.1</version> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>com.alibaba.cloud</groupId> |
||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>org.springframework.cloud</groupId> |
||||
|
<artifactId>spring-cloud-starter-openfeign</artifactId> |
||||
|
</dependency> |
||||
|
<!--mysql--> |
||||
|
<dependency> |
||||
|
<groupId>mysql</groupId> |
||||
|
<artifactId>mysql-connector-java</artifactId> |
||||
|
<scope>runtime</scope> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>com.baomidou</groupId> |
||||
|
<artifactId>mybatis-plus-boot-starter</artifactId> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>com.baomidou</groupId> |
||||
|
<artifactId>mybatis-plus-annotation</artifactId> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>org.projectlombok</groupId> |
||||
|
<artifactId>lombok</artifactId> |
||||
|
<version>1.18.24</version> |
||||
|
<optional>true</optional> |
||||
|
</dependency> |
||||
|
|
||||
|
<dependency> |
||||
|
<groupId>com.yxt</groupId> |
||||
|
<artifactId>yxt-common-base</artifactId> |
||||
|
<version>0.0.1</version> |
||||
|
</dependency> |
||||
|
|
||||
|
<dependency> |
||||
|
<groupId>org.springframework.boot</groupId> |
||||
|
<artifactId>spring-boot-starter-web</artifactId> |
||||
|
</dependency> |
||||
|
|
||||
|
<dependency> |
||||
|
<groupId>com.alibaba.cloud</groupId> |
||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> |
||||
|
</dependency> |
||||
|
|
||||
|
<dependency> |
||||
|
<groupId>org.springframework.cloud</groupId> |
||||
|
<artifactId>spring-cloud-starter-openfeign</artifactId> |
||||
|
</dependency> |
||||
|
|
||||
|
<!--mysql--> |
||||
|
<dependency> |
||||
|
<groupId>mysql</groupId> |
||||
|
<artifactId>mysql-connector-java</artifactId> |
||||
|
<scope>runtime</scope> |
||||
|
</dependency> |
||||
|
|
||||
|
<dependency> |
||||
|
<groupId>com.baomidou</groupId> |
||||
|
<artifactId>mybatis-plus-boot-starter</artifactId> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>com.baomidou</groupId> |
||||
|
<artifactId>mybatis-plus-annotation</artifactId> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>junit</groupId> |
||||
|
<artifactId>junit</artifactId> |
||||
|
<scope>compile</scope> |
||||
|
</dependency> |
||||
|
|
||||
|
<dependency> |
||||
|
<groupId>org.projectlombok</groupId> |
||||
|
<artifactId>lombok</artifactId> |
||||
|
<optional>true</optional> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>org.springframework.boot</groupId> |
||||
|
<artifactId>spring-boot-starter-test</artifactId> |
||||
|
<scope>test</scope> |
||||
|
</dependency> |
||||
|
|
||||
|
<!-- Sa-Token 权限认证,在线文档:https://sa-token.cc --> |
||||
|
<dependency> |
||||
|
<groupId>cn.dev33</groupId> |
||||
|
<artifactId>sa-token-spring-boot-starter</artifactId> |
||||
|
<version>1.37.0</version> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>cn.hutool</groupId> |
||||
|
<artifactId>hutool-all</artifactId> |
||||
|
<version>5.8.23</version> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>cn.hutool</groupId> |
||||
|
<artifactId>hutool-core</artifactId> |
||||
|
<version>5.8.23</version> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>com.google.zxing</groupId> |
||||
|
<artifactId>core</artifactId> |
||||
|
<version>3.5.2</version> |
||||
|
</dependency> |
||||
|
|
||||
|
</dependencies> |
||||
|
|
||||
|
<build> |
||||
|
<plugins> |
||||
|
<plugin> |
||||
|
<groupId>org.springframework.boot</groupId> |
||||
|
<artifactId>spring-boot-maven-plugin</artifactId> |
||||
|
<version>2.5.6</version> |
||||
|
<executions> |
||||
|
<execution> |
||||
|
<goals> |
||||
|
<goal>repackage</goal> |
||||
|
</goals> |
||||
|
</execution> |
||||
|
</executions> |
||||
|
</plugin> |
||||
|
</plugins> |
||||
|
<resources> |
||||
|
<resource> |
||||
|
<directory>src/main/java</directory> |
||||
|
<includes> |
||||
|
<include>**/*Mapper.xml</include> |
||||
|
</includes> |
||||
|
</resource> |
||||
|
<resource> |
||||
|
<directory>src/main/resources</directory> |
||||
|
<includes> |
||||
|
<include>**/*.*</include> |
||||
|
</includes> |
||||
|
<filtering>false</filtering> |
||||
|
</resource> |
||||
|
</resources> |
||||
|
</build> |
||||
|
</project> |
@ -0,0 +1,24 @@ |
|||||
|
package com.yxt.oms; |
||||
|
|
||||
|
import org.springframework.boot.SpringApplication; |
||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication; |
||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; |
||||
|
import org.springframework.cloud.openfeign.EnableFeignClients; |
||||
|
import org.springframework.scheduling.annotation.EnableScheduling; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date ${DATE} ${TIME} |
||||
|
*/ |
||||
|
@SpringBootApplication(scanBasePackages = { |
||||
|
"com.yxt.common.base.config", |
||||
|
"com.yxt.oms" |
||||
|
}) |
||||
|
@EnableDiscoveryClient |
||||
|
@EnableScheduling |
||||
|
@EnableFeignClients |
||||
|
public class OmsApplication { |
||||
|
public static void main(String[] args) { |
||||
|
SpringApplication.run(OmsApplication.class, args); |
||||
|
} |
||||
|
} |
@ -0,0 +1,10 @@ |
|||||
|
package com.yxt.oms.apiadmin; |
||||
|
|
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
@RestController("com.yxt.wms.apiadmin.AdminHomeRest") |
||||
|
@RequestMapping("/apiadmin/home") |
||||
|
public class AdminHomeRest { |
||||
|
|
||||
|
} |
@ -0,0 +1,74 @@ |
|||||
|
package com.yxt.oms.apiadmin.aggregation; |
||||
|
|
||||
|
import com.yxt.common.core.query.PagerQuery; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import com.yxt.common.core.vo.PagerVo; |
||||
|
import com.yxt.oms.biz.func.purchasereceiptbill.PurchaseReceiptBillService; |
||||
|
import com.yxt.oms.biz.func.purchasereceiptbill.PurchaseReceiptBill; |
||||
|
import com.yxt.oms.biz.func.purchasereceiptbill.PurchaseReceiptBillDto; |
||||
|
import com.yxt.oms.biz.func.purchasereceiptbill.PurchaseReceiptBillQuery; |
||||
|
import com.yxt.oms.biz.func.purchasereceiptbill.PurchaseReceiptBillVo; |
||||
|
import com.yxt.oms.utils.OrgPathQuery; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2024/2/26 15:49 |
||||
|
*/ |
||||
|
@Api(tags = "商品品牌") |
||||
|
@RestController |
||||
|
@RequestMapping("/apiadmin/base/basegoodsbrand") |
||||
|
public class PurchaseReceiptBillRest { |
||||
|
|
||||
|
@Autowired |
||||
|
PurchaseReceiptBillService baseBrandInfoService; |
||||
|
|
||||
|
@ApiOperation("分页列表") |
||||
|
@PostMapping("/listPage") |
||||
|
public ResultBean<PagerVo<PurchaseReceiptBillVo>> listPage(@RequestBody PagerQuery<PurchaseReceiptBillQuery> pq) { |
||||
|
return baseBrandInfoService.listPage(pq); |
||||
|
} |
||||
|
|
||||
|
@ApiOperation("查询所有的品牌") |
||||
|
@PostMapping("/listAll") |
||||
|
public ResultBean<List<PurchaseReceiptBill>> listAll(@RequestBody OrgPathQuery query) { |
||||
|
return baseBrandInfoService.listAll(query); |
||||
|
} |
||||
|
|
||||
|
@ApiOperation("保存") |
||||
|
@PostMapping("/save") |
||||
|
public ResultBean<String> save(@RequestBody PurchaseReceiptBillDto dto) { |
||||
|
return baseBrandInfoService.save(dto); |
||||
|
} |
||||
|
|
||||
|
@ApiOperation("初始化") |
||||
|
@GetMapping("/initialization/{sid}") |
||||
|
public ResultBean<PurchaseReceiptBillVo> initialization(@PathVariable("sid") String sid) { |
||||
|
return baseBrandInfoService.initialization(sid); |
||||
|
} |
||||
|
|
||||
|
@ApiOperation("删除") |
||||
|
@DeleteMapping("/delete/{sid}") |
||||
|
public ResultBean delete(@PathVariable("sid") String sid) { |
||||
|
return baseBrandInfoService.delete(sid); |
||||
|
} |
||||
|
|
||||
|
@ApiOperation("根据sid批量删除") |
||||
|
@DeleteMapping("/delBySids") |
||||
|
public ResultBean delBySids(@RequestBody String[] sids){ |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
baseBrandInfoService.delAll(sids); |
||||
|
return rb.success(); |
||||
|
} |
||||
|
|
||||
|
@ApiOperation("更改可用状态") |
||||
|
@GetMapping("/updateIsEnable/{sid}/{isEnable}") |
||||
|
public ResultBean updateIsEnable(@PathVariable("sid") String sid,@PathVariable("isEnable")String isEnable) { |
||||
|
return baseBrandInfoService.updateIsEnable(sid,isEnable); |
||||
|
} |
||||
|
} |
@ -0,0 +1,10 @@ |
|||||
|
package com.yxt.oms.apiwx; |
||||
|
|
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
@RestController("com.yxt.wms.apiwx.WxHomeRest") |
||||
|
@RequestMapping("/apiwx/home") |
||||
|
public class WxHomeRest { |
||||
|
|
||||
|
} |
@ -0,0 +1,42 @@ |
|||||
|
package com.yxt.oms.biz.func.purchasereceiptbill; |
||||
|
|
||||
|
import com.yxt.common.core.domain.BaseEntity; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2024/2/26 13:36 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class PurchaseReceiptBill extends BaseEntity { |
||||
|
|
||||
|
|
||||
|
private String sourceBillSid;//来源单sid(工单sid)
|
||||
|
private String sourceBillNo;//来源单编号
|
||||
|
private String billNo;//单据编号
|
||||
|
private String createDate;//单据日期
|
||||
|
private String createUserSid;//制单人sid
|
||||
|
private String createByName;//制单人姓名
|
||||
|
private String purchaseType;//采购类型(厂家采购、外采)
|
||||
|
private String supplierSid;//供应商sid
|
||||
|
private String supplierName;//供应商名称
|
||||
|
private String supplierPhone;//供应商联系电话
|
||||
|
private String billType;//票据类型(不含税、增值税、普通税、已含增值税)
|
||||
|
private String markupType;//加价方式(统一加价率、区间加价率、仓库加价率)
|
||||
|
private String priceStrategy;//进价不同时的价格策略(加权平均、分别计价)
|
||||
|
private String isInvoicing;//是否需要开发票(是1,否0)
|
||||
|
private String invoiceCode;//发票号码
|
||||
|
private String tempMarkupRate;//临时加价率
|
||||
|
private String purchaserSid;//采购员sid(单选)
|
||||
|
private String purchaserName;//
|
||||
|
private String storekeeperSid;//库管员sid(单选)
|
||||
|
private String storekeeperName;//
|
||||
|
private String errorAmount;//误差调整金额
|
||||
|
private String freight;//运费
|
||||
|
private String discountAmount;//优惠金额
|
||||
|
private String payableAmount;//应付金额(=采购金额+运费-优惠金额)
|
||||
|
private String useOrgSid;//使用组织sid
|
||||
|
private String createOrgSid;//创建组织sid
|
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,56 @@ |
|||||
|
package com.yxt.oms.biz.func.purchasereceiptbill; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.yxt.common.core.dto.Dto; |
||||
|
import com.yxt.oms.biz.func.purchasereceiptbilldetail.PurchaseReceiptBillDetailDto; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2024/2/26 13:38 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class PurchaseReceiptBillDto implements Dto { |
||||
|
private String id; |
||||
|
private String sid; |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
private Date createTime; |
||||
|
private String remarks; |
||||
|
private String isEnable; |
||||
|
private String sourceBillSid;//来源单sid(工单sid)
|
||||
|
private String sourceBillNo;//来源单编号
|
||||
|
private String billNo;//单据编号
|
||||
|
private String createDate;//单据日期
|
||||
|
private String createUserSid;//制单人sid
|
||||
|
private String createByName;//制单人姓名
|
||||
|
private String purchaseType;//采购类型(厂家采购、外采)
|
||||
|
private String supplierSid;//供应商sid
|
||||
|
private String supplierName;//供应商名称
|
||||
|
private String supplierPhone;//供应商联系电话
|
||||
|
private String billType;//票据类型(不含税、增值税、普通税、已含增值税)
|
||||
|
private String markupType;//加价方式(统一加价率、区间加价率、仓库加价率)
|
||||
|
private String priceStrategy;//进价不同时的价格策略(加权平均、分别计价)
|
||||
|
private String isInvoicing;//是否需要开发票(是1,否0)
|
||||
|
private String invoiceCode;//发票号码
|
||||
|
private String tempMarkupRate;//临时加价率
|
||||
|
private String purchaserSid;//采购员sid(单选)
|
||||
|
private String purchaserName;//
|
||||
|
private String storekeeperSid;//库管员sid(单选)
|
||||
|
private String storekeeperName;//
|
||||
|
private String errorAmount;//误差调整金额
|
||||
|
private String freight;//运费
|
||||
|
private String discountAmount;//优惠金额
|
||||
|
private String payableAmount;//应付金额(=采购金额+运费-优惠金额)
|
||||
|
private String useOrgSid;//使用组织sid
|
||||
|
private String createOrgSid;//创建组织sid
|
||||
|
private String contact;//联系人
|
||||
|
private String mobile;//联系人手机
|
||||
|
private String goodsOwnerSid;//货主sid
|
||||
|
private String goodsOwner;//货主
|
||||
|
private List<PurchaseReceiptBillDetailDto> purchaseReceiptBillList=new ArrayList<>(); |
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
package com.yxt.oms.biz.func.purchasereceiptbill; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.core.toolkit.Constants; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2024/2/26 13:40 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface PurchaseReceiptBillMapper extends BaseMapper<PurchaseReceiptBill> { |
||||
|
|
||||
|
IPage<PurchaseReceiptBillVo> listPage(IPage<PurchaseReceiptBill> page, @Param(Constants.WRAPPER) QueryWrapper<PurchaseReceiptBill> qw); |
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
<mapper namespace="com.yxt.oms.biz.func.purchasereceiptbill.PurchaseReceiptBillMapper"> |
||||
|
<!-- <where> ${ew.sqlSegment} </where>--> |
||||
|
<!-- ${ew.customSqlSegment} --> |
||||
|
|
||||
|
<select id="listPage" resultType="com.yxt.oms.biz.func.purchasereceiptbill.PurchaseReceiptBillVo"> |
||||
|
select |
||||
|
* |
||||
|
from base_brand_info |
||||
|
<where> |
||||
|
${ew.sqlSegment} |
||||
|
</where> |
||||
|
</select> |
||||
|
</mapper> |
@ -0,0 +1,13 @@ |
|||||
|
package com.yxt.oms.biz.func.purchasereceiptbill; |
||||
|
|
||||
|
import com.yxt.common.core.query.Query; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2024/2/26 13:37 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class PurchaseReceiptBillQuery implements Query { |
||||
|
private String name; |
||||
|
} |
@ -0,0 +1,99 @@ |
|||||
|
package com.yxt.oms.biz.func.purchasereceiptbill; |
||||
|
|
||||
|
import com.yxt.common.base.config.component.FileUploadComponent; |
||||
|
import com.yxt.common.base.service.MybatisBaseService; |
||||
|
import com.yxt.common.core.query.PagerQuery; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import com.yxt.common.core.vo.PagerVo; |
||||
|
import com.yxt.oms.biz.func.purchasereceiptbilldetail.PurchaseReceiptBillDetailDto; |
||||
|
import com.yxt.oms.biz.func.warehouseansbill.WarehouseAnsBillDto; |
||||
|
import com.yxt.oms.biz.func.warehouseansbilldetail.WarehouseAnsBillDetailDto; |
||||
|
import com.yxt.oms.feign.purchase.purchasereceiptbill.PurchaseReceiptBillFeign; |
||||
|
import com.yxt.oms.feign.warehouse.warehouseansbill.WarehouseAnsBillFeign; |
||||
|
import com.yxt.oms.utils.OrgPathQuery; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2024/2/26 13:40 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class PurchaseReceiptBillService extends MybatisBaseService<PurchaseReceiptBillMapper, PurchaseReceiptBill> { |
||||
|
@Autowired |
||||
|
private FileUploadComponent fileUploadComponent; |
||||
|
@Autowired |
||||
|
PurchaseReceiptBillFeign purchaseReceiptBillFeign; |
||||
|
@Autowired |
||||
|
WarehouseAnsBillFeign warehouseAnsBillFeignl; |
||||
|
|
||||
|
public ResultBean<PagerVo<PurchaseReceiptBillVo>> listPage(PagerQuery<PurchaseReceiptBillQuery> pq) { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
return purchaseReceiptBillFeign.listPage(pq); |
||||
|
} |
||||
|
public ResultBean<List<PurchaseReceiptBill>> listAll(OrgPathQuery query) { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
|
||||
|
return purchaseReceiptBillFeign.listAll(query); |
||||
|
} |
||||
|
public ResultBean<String> save(PurchaseReceiptBillDto dto) { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
WarehouseAnsBillDto dto1=new WarehouseAnsBillDto(); |
||||
|
dto1.setSourceBillNo(""); |
||||
|
dto1.setBusTypeKey("采购预约"); |
||||
|
dto1.setBusTypeValue("采购预约"); |
||||
|
dto1.setCreateByName(dto.getCreateByName()); |
||||
|
dto1.setBillState(1); |
||||
|
dto1.setReviewStatus(""); |
||||
|
dto1.setRefuseReason(""); |
||||
|
dto1.setContact(dto.getContact()); |
||||
|
dto1.setMobile(dto.getMobile()); |
||||
|
dto1.setGoodsOwner(dto.getGoodsOwner()); |
||||
|
dto1.setGoodsOwnerSid(dto.getGoodsOwnerSid()); |
||||
|
dto1.setSupplierSid(dto.getSupplierSid()); |
||||
|
dto1.setSupplierName(dto.getSupplierName()); |
||||
|
dto1.setDeliveryDate(new Date()); |
||||
|
dto1.setUseOrgSid(dto.getUseOrgSid()); |
||||
|
dto1.setCreateBySid(dto.getCreateOrgSid()); |
||||
|
List<WarehouseAnsBillDetailDto> wmsAnsBillDetailList = new ArrayList<>(); |
||||
|
for (PurchaseReceiptBillDetailDto purchaseReceiptBillDetailDto : dto.getPurchaseReceiptBillList()) { |
||||
|
WarehouseAnsBillDetailDto d=new WarehouseAnsBillDetailDto(); |
||||
|
d.setGoodsSkuSid(purchaseReceiptBillDetailDto.getGoodsSid()); |
||||
|
d.setGoodsSkuTitle(purchaseReceiptBillDetailDto.getGoodsName()); |
||||
|
d.setUnit(purchaseReceiptBillDetailDto.getUnit()); |
||||
|
d.setCost(purchaseReceiptBillDetailDto.getCost()); |
||||
|
d.setOrderCount(purchaseReceiptBillDetailDto.getCount()); |
||||
|
d.setTaxAmount(purchaseReceiptBillDetailDto.getTaxAmount()); |
||||
|
d.setTaxPrice(purchaseReceiptBillDetailDto.getTaxPrice()); |
||||
|
d.setAmount(purchaseReceiptBillDetailDto.getAmount()); |
||||
|
wmsAnsBillDetailList.add(d); |
||||
|
} |
||||
|
warehouseAnsBillFeignl.saveBill(dto1); |
||||
|
return purchaseReceiptBillFeign.saveOrUpdate(dto); |
||||
|
} |
||||
|
|
||||
|
public ResultBean<PurchaseReceiptBillVo> initialization(String sid) { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
|
||||
|
return purchaseReceiptBillFeign.initialization(sid); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
public ResultBean delete(String sid) { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
return rb.success().setMsg("成功"); |
||||
|
} |
||||
|
public ResultBean delAll(String[] sids) { |
||||
|
return purchaseReceiptBillFeign.delBySids(sids); |
||||
|
} |
||||
|
public ResultBean updateIsEnable(String sid,String isEnable) { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
return purchaseReceiptBillFeign.updateIsEnable(sid,isEnable); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,52 @@ |
|||||
|
package com.yxt.oms.biz.func.purchasereceiptbill; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.yxt.common.core.vo.Vo; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2024/2/26 13:37 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class PurchaseReceiptBillVo implements Vo { |
||||
|
private String id; |
||||
|
private String sid; |
||||
|
private String lockVersion; |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
private Date createTime; |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
private Date modifyTime; |
||||
|
private String remarks; |
||||
|
private String isEnable; |
||||
|
private String state; |
||||
|
private String isDelete; |
||||
|
private String sourceBillSid;//来源单sid(工单sid)
|
||||
|
private String sourceBillNo;//来源单编号
|
||||
|
private String billNo;//单据编号
|
||||
|
private String createDate;//单据日期
|
||||
|
private String createUserSid;//制单人sid
|
||||
|
private String createByName;//制单人姓名
|
||||
|
private String purchaseType;//采购类型(厂家采购、外采)
|
||||
|
private String supplierSid;//供应商sid
|
||||
|
private String supplierName;//供应商名称
|
||||
|
private String supplierPhone;//供应商联系电话
|
||||
|
private String billType;//票据类型(不含税、增值税、普通税、已含增值税)
|
||||
|
private String markupType;//加价方式(统一加价率、区间加价率、仓库加价率)
|
||||
|
private String priceStrategy;//进价不同时的价格策略(加权平均、分别计价)
|
||||
|
private String isInvoicing;//是否需要开发票(是1,否0)
|
||||
|
private String invoiceCode;//发票号码
|
||||
|
private String tempMarkupRate;//临时加价率
|
||||
|
private String purchaserSid;//采购员sid(单选)
|
||||
|
private String purchaserName;//
|
||||
|
private String storekeeperSid;//库管员sid(单选)
|
||||
|
private String storekeeperName;//
|
||||
|
private String errorAmount;//误差调整金额
|
||||
|
private String freight;//运费
|
||||
|
private String discountAmount;//优惠金额
|
||||
|
private String payableAmount;//应付金额(=采购金额+运费-优惠金额)
|
||||
|
private String useOrgSid;//使用组织sid
|
||||
|
private String createOrgSid;//创建组织sid
|
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
package com.yxt.oms.biz.func.purchasereceiptbilldetail; |
||||
|
|
||||
|
import com.yxt.common.core.domain.BaseEntity; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2024/2/26 13:36 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class PurchaseReceiptBillDetail extends BaseEntity { |
||||
|
|
||||
|
|
||||
|
private String billSid;//单据sid
|
||||
|
private String goodsSid;//商品sid
|
||||
|
private String goodsName;//商品名称
|
||||
|
private String goodsCode;//商品编码(图号)
|
||||
|
private String specification;//规格
|
||||
|
private String goodsModel;//型号
|
||||
|
private double currentCount;//当前库存数量
|
||||
|
private String unit;//计量单位
|
||||
|
private String warehouseSid;//仓库sid
|
||||
|
private String warehouseName;//仓库名称
|
||||
|
private String position;//货位
|
||||
|
private double cost;//单位成本(进货价)
|
||||
|
private double count;//采购数量
|
||||
|
private double taxAmount;//税额(
|
||||
|
private double taxPrice;//含税价
|
||||
|
private double amount;//采购金额
|
||||
|
private double price1;//销售价1
|
||||
|
private double price2;//销售价2
|
||||
|
|
||||
|
} |
@ -0,0 +1,39 @@ |
|||||
|
package com.yxt.oms.biz.func.purchasereceiptbilldetail; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.yxt.common.core.dto.Dto; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2024/2/26 13:38 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class PurchaseReceiptBillDetailDto implements Dto { |
||||
|
private String id; |
||||
|
private String sid; |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
private Date createTime; |
||||
|
private String remarks; |
||||
|
private String isEnable; |
||||
|
private String billSid;//单据sid
|
||||
|
private String goodsSid;//商品sid
|
||||
|
private String goodsName;//商品名称
|
||||
|
private String goodsCode;//商品编码(图号)
|
||||
|
private String specification;//规格
|
||||
|
private String goodsModel;//型号
|
||||
|
private double currentCount;//当前库存数量
|
||||
|
private String unit;//计量单位
|
||||
|
private String warehouseSid;//仓库sid
|
||||
|
private String warehouseName;//仓库名称
|
||||
|
private String position;//货位
|
||||
|
private double cost;//单位成本(进货价)
|
||||
|
private double count;//采购数量
|
||||
|
private double taxAmount;//税额(
|
||||
|
private double taxPrice;//含税价
|
||||
|
private double amount;//采购金额
|
||||
|
private double price1;//销售价1
|
||||
|
private double price2;//销售价2
|
||||
|
} |
@ -0,0 +1,13 @@ |
|||||
|
package com.yxt.oms.biz.func.purchasereceiptbilldetail; |
||||
|
|
||||
|
import com.yxt.common.core.query.Query; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2024/2/26 13:37 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class PurchaseReceiptBillDetailQuery implements Query { |
||||
|
private String name; |
||||
|
} |
@ -0,0 +1,44 @@ |
|||||
|
package com.yxt.oms.biz.func.purchasereceiptbilldetail; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.yxt.common.core.vo.Vo; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2024/2/26 13:37 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class PurchaseReceiptBillDetailVo implements Vo { |
||||
|
private String id; |
||||
|
private String sid; |
||||
|
private String lockVersion; |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
private Date createTime; |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
private Date modifyTime; |
||||
|
private String remarks; |
||||
|
private String isEnable; |
||||
|
private String state; |
||||
|
private String isDelete; |
||||
|
private String billSid;//单据sid
|
||||
|
private String goodsSid;//商品sid
|
||||
|
private String goodsName;//商品名称
|
||||
|
private String goodsCode;//商品编码(图号)
|
||||
|
private String specification;//规格
|
||||
|
private String goodsModel;//型号
|
||||
|
private double currentCount;//当前库存数量
|
||||
|
private String unit;//计量单位
|
||||
|
private String warehouseSid;//仓库sid
|
||||
|
private String warehouseName;//仓库名称
|
||||
|
private String position;//货位
|
||||
|
private double cost;//单位成本(进货价)
|
||||
|
private double count;//采购数量
|
||||
|
private double taxAmount;//税额(
|
||||
|
private double taxPrice;//含税价
|
||||
|
private double amount;//采购金额
|
||||
|
private double price1;//销售价1
|
||||
|
private double price2;//销售价2
|
||||
|
} |
@ -0,0 +1,53 @@ |
|||||
|
package com.yxt.oms.biz.func.warehouseansbill; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.yxt.common.core.domain.BaseEntity; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* @description: 预期到货通知单 |
||||
|
* @author: dimengzhe |
||||
|
* @date: 2024/4/9 |
||||
|
**/ |
||||
|
@Data |
||||
|
public class WarehouseAnsBill extends BaseEntity { |
||||
|
|
||||
|
@ApiModelProperty("外部单号(业务单据编号)") |
||||
|
private String sourceBillNo; |
||||
|
@ApiModelProperty("单据编号") |
||||
|
private String billNo; |
||||
|
@ApiModelProperty("业务类型key(采购预约、调拨预约、其他预约)") |
||||
|
private String busTypeKey; |
||||
|
@ApiModelProperty("业务类型value(采购预约、调拨预约、其他预约)") |
||||
|
private String busTypeValue; |
||||
|
@ApiModelProperty("制单人姓名") |
||||
|
private String createByName; |
||||
|
@ApiModelProperty("货物状态") |
||||
|
private Integer billState; |
||||
|
@ApiModelProperty("审核状态(待审核、审核通过、审核拒绝)") |
||||
|
private String reviewStatus; |
||||
|
@ApiModelProperty("拒绝原因") |
||||
|
private String refuseReason; |
||||
|
@ApiModelProperty("联系人") |
||||
|
private String contact; |
||||
|
@ApiModelProperty("联系人手机") |
||||
|
private String mobile; |
||||
|
@ApiModelProperty("供应商sid") |
||||
|
private String supplierSid; |
||||
|
@ApiModelProperty("供应商名称") |
||||
|
private String supplierName; |
||||
|
@ApiModelProperty("货主sid") |
||||
|
private String goodsOwnerSid; |
||||
|
@ApiModelProperty("货主") |
||||
|
private String goodsOwner; |
||||
|
@ApiModelProperty("预计到货日期") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
private Date deliveryDate; |
||||
|
@ApiModelProperty("使用组织sid") |
||||
|
private String useOrgSid; |
||||
|
@ApiModelProperty("创建组织sid") |
||||
|
private String createOrgSid; |
||||
|
} |
@ -0,0 +1,56 @@ |
|||||
|
package com.yxt.oms.biz.func.warehouseansbill; |
||||
|
|
||||
|
import com.yxt.oms.biz.func.warehouseansbilldetail.WarehouseAnsBillDetailDto; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: dimengzhe |
||||
|
* @date: 2024/4/9 |
||||
|
**/ |
||||
|
@Data |
||||
|
public class WarehouseAnsBillDto { |
||||
|
|
||||
|
private String sid; |
||||
|
private String createBySid; |
||||
|
|
||||
|
@ApiModelProperty("外部单号(业务单据编号)") |
||||
|
private String sourceBillNo; |
||||
|
@ApiModelProperty("业务类型key(采购预约、调拨预约、其他预约)") |
||||
|
private String busTypeKey; |
||||
|
@ApiModelProperty("业务类型value(采购预约、调拨预约、其他预约)") |
||||
|
private String busTypeValue; |
||||
|
@ApiModelProperty("制单人姓名") |
||||
|
private String createByName; |
||||
|
@ApiModelProperty("货物状态(在途、部分收货、已收货、已取消)") |
||||
|
private Integer billState; |
||||
|
@ApiModelProperty("审核状态(待审核、审核通过、审核拒绝)") |
||||
|
private String reviewStatus; |
||||
|
@ApiModelProperty("拒绝原因") |
||||
|
private String refuseReason; |
||||
|
@ApiModelProperty("联系人") |
||||
|
private String contact; |
||||
|
@ApiModelProperty("联系人手机") |
||||
|
private String mobile; |
||||
|
@ApiModelProperty("供应商sid") |
||||
|
private String supplierSid; |
||||
|
@ApiModelProperty("供应商名称") |
||||
|
private String supplierName; |
||||
|
@ApiModelProperty("货主sid") |
||||
|
private String goodsOwnerSid; |
||||
|
@ApiModelProperty("货主") |
||||
|
private String goodsOwner; |
||||
|
@ApiModelProperty("预计到货日期") |
||||
|
private Date deliveryDate; |
||||
|
@ApiModelProperty("使用组织sid") |
||||
|
private String useOrgSid; |
||||
|
@ApiModelProperty("创建组织sid") |
||||
|
private String createOrgSid; |
||||
|
|
||||
|
private List<WarehouseAnsBillDetailDto> wmsAnsBillDetailList = new ArrayList<>(); |
||||
|
} |
@ -0,0 +1,37 @@ |
|||||
|
package com.yxt.oms.biz.func.warehouseansbill; |
||||
|
|
||||
|
import com.yxt.common.core.query.Query; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: dimengzhe |
||||
|
* @date: 2024/4/11 |
||||
|
**/ |
||||
|
@Data |
||||
|
public class WarehouseAnsBillQuery implements Query { |
||||
|
|
||||
|
@ApiModelProperty("单据编号") |
||||
|
private String billNo; |
||||
|
@ApiModelProperty("开始时间") |
||||
|
private String createTimeStart; |
||||
|
@ApiModelProperty("结束时间") |
||||
|
private String createTimeEnd; |
||||
|
@ApiModelProperty("业务类型") |
||||
|
private String busTypeKey; |
||||
|
@ApiModelProperty("供应商") |
||||
|
private String supplierName; |
||||
|
@ApiModelProperty("预期到货日期开始时间") |
||||
|
private String deliveryDateStart; |
||||
|
@ApiModelProperty("预期到货日期结束时间") |
||||
|
private String deliveryDateEnd; |
||||
|
//单据状态
|
||||
|
private String billState; |
||||
|
|
||||
|
@ApiModelProperty("审核状态") |
||||
|
private String reviewStatus; |
||||
|
|
||||
|
@ApiModelProperty("外部单号(业务单据编号)") |
||||
|
private String sourceBillNo; |
||||
|
} |
@ -0,0 +1,51 @@ |
|||||
|
package com.yxt.oms.biz.func.warehouseansbill; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: dimengzhe |
||||
|
* @date: 2024/4/11 |
||||
|
**/ |
||||
|
@Data |
||||
|
public class WarehouseAnsBillVo { |
||||
|
|
||||
|
|
||||
|
private String sid; |
||||
|
@ApiModelProperty("单据编号") |
||||
|
private String billNo; |
||||
|
@ApiModelProperty("单据日期") |
||||
|
private String createTime; |
||||
|
@ApiModelProperty("制单人姓名") |
||||
|
private String createByName; |
||||
|
@ApiModelProperty("外部单号(业务单据编号)") |
||||
|
private String sourceBillNo; |
||||
|
@ApiModelProperty("业务类型value(采购预约、调拨预约、其他预约)") |
||||
|
private String busTypeValue; |
||||
|
@ApiModelProperty("供应商名称") |
||||
|
private String supplierName; |
||||
|
@ApiModelProperty("联系人") |
||||
|
private String contact; |
||||
|
@ApiModelProperty("联系人手机") |
||||
|
private String mobile; |
||||
|
@ApiModelProperty("预计到货日期") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") |
||||
|
private String deliveryDate; |
||||
|
|
||||
|
//单据状态
|
||||
|
private String billState; |
||||
|
|
||||
|
@ApiModelProperty("审核状态(待审核、审核通过、审核拒绝)") |
||||
|
private String reviewStatus; |
||||
|
@ApiModelProperty("拒绝原因") |
||||
|
private String refuseReason; |
||||
|
|
||||
|
/* @ApiModelProperty("货物状态(在途、部分收货、已收货、已取消)") |
||||
|
private String billStateValue; |
||||
|
@ApiModelProperty("货主") |
||||
|
private String goodsOwner;*/ |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,60 @@ |
|||||
|
package com.yxt.oms.biz.func.warehouseansbill; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.yxt.oms.biz.func.warehouseansbilldetail.WarehouseAnsListDetailsVo; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: dimengzhe |
||||
|
* @date: 2024/4/12 |
||||
|
**/ |
||||
|
@Data |
||||
|
public class WarehouseAnsDetailsVo { |
||||
|
private String billNo; |
||||
|
@ApiModelProperty("制单人姓名") |
||||
|
private String createByName; |
||||
|
@ApiModelProperty("单据日期") |
||||
|
private String createTime; |
||||
|
@ApiModelProperty("外部单号(业务单据编号)") |
||||
|
private String sourceBillNo; |
||||
|
@ApiModelProperty("业务类型key(采购预约、调拨预约、其他预约)") |
||||
|
private String busTypeKey; |
||||
|
@ApiModelProperty("业务类型value(采购预约、调拨预约、其他预约)") |
||||
|
private String busTypeValue; |
||||
|
@ApiModelProperty("供应商sid") |
||||
|
private String supplierSid; |
||||
|
@ApiModelProperty("供应商名称") |
||||
|
private String supplierName; |
||||
|
@ApiModelProperty("预计到货日期") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") |
||||
|
private String deliveryDate; |
||||
|
|
||||
|
//单据状态
|
||||
|
private String billState; |
||||
|
|
||||
|
@ApiModelProperty("审核状态(待审核、审核通过、审核拒绝)") |
||||
|
private String reviewStatus; |
||||
|
|
||||
|
/* @ApiModelProperty("货物状态(在途、部分收货、已收货、已取消)") |
||||
|
private Integer billState;*/ |
||||
|
|
||||
|
@ApiModelProperty("拒绝原因") |
||||
|
private String refuseReason; |
||||
|
/* @ApiModelProperty("联系人") |
||||
|
private String contact; |
||||
|
@ApiModelProperty("联系人手机") |
||||
|
private String mobile; |
||||
|
|
||||
|
@ApiModelProperty("货主sid") |
||||
|
private String goodsOwnerSid; |
||||
|
@ApiModelProperty("货主") |
||||
|
private String goodsOwner;*/ |
||||
|
|
||||
|
|
||||
|
private List<WarehouseAnsListDetailsVo> list = new ArrayList<>(); |
||||
|
} |
@ -0,0 +1,38 @@ |
|||||
|
package com.yxt.oms.biz.func.warehouseansbilldetail; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: dimengzhe |
||||
|
* @date: 2024/4/9 |
||||
|
**/ |
||||
|
@Data |
||||
|
public class WarehouseAnsBillDetailDto { |
||||
|
|
||||
|
@ApiModelProperty("商品基础信息sid") |
||||
|
private String goodSpuSid; |
||||
|
@ApiModelProperty("商品名称") |
||||
|
private String goodsSpuName; |
||||
|
@ApiModelProperty("商品Skusid") |
||||
|
private String goodsSkuSid; |
||||
|
@ApiModelProperty("商品名称") |
||||
|
private String goodsSkuTitle; |
||||
|
@ApiModelProperty("商品编码(图号)") |
||||
|
private String goodsSkuCode; |
||||
|
@ApiModelProperty("规格型号") |
||||
|
private String goodsSkuOwnSpec; |
||||
|
@ApiModelProperty("计量单位") |
||||
|
private String unit; |
||||
|
@ApiModelProperty("单位成本(采购价)") |
||||
|
private double cost; |
||||
|
@ApiModelProperty("预约数量(采购订单数量)") |
||||
|
private double orderCount; |
||||
|
@ApiModelProperty("税额") |
||||
|
private double taxAmount; |
||||
|
@ApiModelProperty("含税价") |
||||
|
private double taxPrice; |
||||
|
@ApiModelProperty("金额") |
||||
|
private double amount; |
||||
|
} |
@ -0,0 +1,56 @@ |
|||||
|
package com.yxt.oms.biz.func.warehouseansbilldetail; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: dimengzhe |
||||
|
* @date: 2024/4/11 |
||||
|
**/ |
||||
|
@Data |
||||
|
public class WarehouseAnsListDetailsVo { |
||||
|
@ApiModelProperty("商品名称") |
||||
|
private String goodsSkuTitle; |
||||
|
@ApiModelProperty("商品编码(图号)") |
||||
|
private String goodsSkuCode; |
||||
|
@ApiModelProperty("规格型号") |
||||
|
private String goodsSkuOwnSpec; |
||||
|
@ApiModelProperty("计量单位") |
||||
|
private String unit; |
||||
|
|
||||
|
//仓库
|
||||
|
private String warehouseName; |
||||
|
//库位
|
||||
|
private String warehouseRack; |
||||
|
|
||||
|
//预约数量
|
||||
|
@ApiModelProperty("预约数量(采购订单数量)") |
||||
|
private String orderCount; |
||||
|
//待收货数量
|
||||
|
@ApiModelProperty("待入库数量-根据收货单计算") |
||||
|
private Integer waitInCount; |
||||
|
//已收货数量
|
||||
|
@ApiModelProperty("实际入库数量-根据收货单计算") |
||||
|
private Integer actualInCount; |
||||
|
//入库价
|
||||
|
@ApiModelProperty("单位成本(采购价)") |
||||
|
private String cost; |
||||
|
@ApiModelProperty("税额") |
||||
|
private String taxAmount; |
||||
|
@ApiModelProperty("含税价") |
||||
|
private String taxPrice; |
||||
|
//采购金额
|
||||
|
@ApiModelProperty("金额") |
||||
|
private String amount; |
||||
|
|
||||
|
|
||||
|
/* @ApiModelProperty("商品基础信息sid") |
||||
|
private String goodSpuSid; |
||||
|
@ApiModelProperty("商品名称") |
||||
|
private String goodsSpuName; |
||||
|
@ApiModelProperty("商品Skusid") |
||||
|
private String goodsSkuSid;*/ |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,4 @@ |
|||||
|
/** |
||||
|
* 宇信通 仓库管理 项目后台逻辑和接口 |
||||
|
*/ |
||||
|
package com.yxt.oms.biz; |
@ -0,0 +1,114 @@ |
|||||
|
package com.yxt.oms.config;//package com.yxt.wms.config;
|
||||
|
//
|
||||
|
//import cn.dev33.satoken.interceptor.SaInterceptor;
|
||||
|
//import cn.dev33.satoken.stp.StpUtil;
|
||||
|
//import org.springframework.beans.factory.annotation.Value;
|
||||
|
//import org.springframework.context.annotation.Configuration;
|
||||
|
//import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
|
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
//
|
||||
|
///**
|
||||
|
// * @author wangpengfei
|
||||
|
// * @date 2023/5/16 14:43
|
||||
|
// */
|
||||
|
//@Configuration
|
||||
|
//public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
|
// @Value("${image.url.prefix:http://127.0.0.1:8080/upload/}")
|
||||
|
// private String urlPrefix;
|
||||
|
// // 注册 Sa-Token 拦截器
|
||||
|
// @Override
|
||||
|
// public void addInterceptors(InterceptorRegistry registry) {
|
||||
|
// // 注册 Sa-Token 拦截器,校验规则为 StpUtil.checkLogin() 登录校验。
|
||||
|
//
|
||||
|
// registry.addInterceptor(new SaInterceptor(handler -> StpUtil.checkLogin()))
|
||||
|
// .addPathPatterns("/**")
|
||||
|
// .excludePathPatterns("/sysuser/doLogin")
|
||||
|
// .excludePathPatterns("/lpkgiftcard/gifCardByCustomerSid")
|
||||
|
// .excludePathPatterns("/empcardgift/gifCardByCustomerSid")
|
||||
|
// .excludePathPatterns("/empcard/getEmpCardByCustomerSid")
|
||||
|
// .excludePathPatterns("/lpkgiftcard/getGifCardBySid/**")
|
||||
|
// .excludePathPatterns("/empcardgift/getGifCardBySid/**")
|
||||
|
// .excludePathPatterns("/empcard/getEmpCardBySid/**")
|
||||
|
// .excludePathPatterns("/lpkgiftcard/isSaturAndSun/**")
|
||||
|
// .excludePathPatterns("/empcardgift/isSaturAndSun/**")
|
||||
|
// .excludePathPatterns("/empcard/isSaturAndSun/**")
|
||||
|
// .excludePathPatterns("/lpkgiftcard/getReservationBySid/**")
|
||||
|
// .excludePathPatterns("/lpksreservoorder/submission")
|
||||
|
// .excludePathPatterns("/lpksreservoorder/exportExcelByStore")
|
||||
|
// .excludePathPatterns("/empsreservoorder/createNewUserBagOrder")
|
||||
|
// .excludePathPatterns("/lpksreservoorders/submission")
|
||||
|
// .excludePathPatterns("/empsreservoorder/ordersList")
|
||||
|
// .excludePathPatterns("/empsreservoorder/submission")
|
||||
|
// .excludePathPatterns("/empsreservoorder/submissionEmp")
|
||||
|
// .excludePathPatterns("/empcardgift/generateCard")
|
||||
|
// .excludePathPatterns("/lpkgiftcard/bindCard")
|
||||
|
// .excludePathPatterns("/empcard/bindCard")
|
||||
|
// .excludePathPatterns("/lpksreservoorder/orderByCardSid/**")
|
||||
|
// .excludePathPatterns("/lpksreservoorder/orderListByUserSid/**")
|
||||
|
// .excludePathPatterns("/lpksreservoorder/orderDetails/**")
|
||||
|
// .excludePathPatterns("/newcomerrecorecord/recommendNewUsers")
|
||||
|
// .excludePathPatterns("/newcomerrecorecord/recommendedAssistance")
|
||||
|
// .excludePathPatterns("/newcomerrecorecord/recordList/**")
|
||||
|
// .excludePathPatterns("/transferrecords/transferRecordsList")
|
||||
|
// .excludePathPatterns("/empsreservoorder/createVegeOrder")
|
||||
|
// .excludePathPatterns("/empsreservoorder/OrderDetails/**")
|
||||
|
// .excludePathPatterns("/empsreservoorder/changePayState/**")
|
||||
|
// .excludePathPatterns("/lpkgoods/goodsDetails/**")
|
||||
|
// .excludePathPatterns("/lpkstore/getAllStoreByQuery")
|
||||
|
// .excludePathPatterns("/vegetablecellar/receiveTransferGoods")
|
||||
|
// .excludePathPatterns("/transferrecords/submission")
|
||||
|
// .excludePathPatterns("/lpkgiftcard/getCardByBank")
|
||||
|
// .excludePathPatterns("/empcard/getEmpCard")
|
||||
|
// .excludePathPatterns("/empcardgift/shareEmpCard/**")
|
||||
|
// .excludePathPatterns("/empcardgift/generateEmpCardGift")
|
||||
|
// .excludePathPatterns("/empcardgift/generateEmpCard")
|
||||
|
// .excludePathPatterns("/lpkcustomer/wxSilentLogin")
|
||||
|
// .excludePathPatterns("/lpkgiftcard/gifCardsByCustomerSid")
|
||||
|
// .excludePathPatterns("/lpkgoods/getAllGiftBag")
|
||||
|
// .excludePathPatterns("/appletgiftbag/getGiftBagBySid/**")
|
||||
|
// .excludePathPatterns("/appletgiftbag/appletGiftBagList")
|
||||
|
// .excludePathPatterns("/lpkgiftcard/cardShareDetail/**")
|
||||
|
// .excludePathPatterns("/lpkgiftcard/cardShareGoodsDetail/**")
|
||||
|
// .excludePathPatterns("/empcardgift/generateTopEmpCard/**")
|
||||
|
// .excludePathPatterns("/empsreservoorder/createOrder")
|
||||
|
// .excludePathPatterns("/appletgiftbag/recommendRecord/**")
|
||||
|
// //2024-01-17
|
||||
|
// .excludePathPatterns("/lpkgiftcard/getAllGoodsType/**")
|
||||
|
// .excludePathPatterns("/appletnotice/getNotice")
|
||||
|
// .excludePathPatterns("/empsreservoorder/getPreOrder")
|
||||
|
// .excludePathPatterns("/lpkgoods/getAllGoodsType/**")
|
||||
|
// .excludePathPatterns("/transferrecords/submission")
|
||||
|
// .excludePathPatterns("/vegetablecellar/receiveTransferGoods")
|
||||
|
// .excludePathPatterns("/customerstore/isSaturAndSun")
|
||||
|
// .excludePathPatterns("/lpkgiftcard/getGoodsByType/**")
|
||||
|
// .excludePathPatterns("/lpkgoods/getGoodsTypeAndBrand")
|
||||
|
// .excludePathPatterns("/lpkgoods/getGoodsByType")
|
||||
|
// .excludePathPatterns("/lpksreservoorders/orderListByUserSid")
|
||||
|
// .excludePathPatterns("/appletgiftbag/newUserQuota")
|
||||
|
// .excludePathPatterns("/shoppingcart/addShoppingCart")
|
||||
|
// .excludePathPatterns("/shoppingcart/getGoodsWeight")
|
||||
|
// .excludePathPatterns("/shoppingcart/shoppingCartList")
|
||||
|
// .excludePathPatterns("/shoppingcart/delShoppingCart/**")
|
||||
|
// .excludePathPatterns("/lpkgoods/vegeCellarTypeList")
|
||||
|
// .excludePathPatterns("/vegetablecellar/addGoods/**")
|
||||
|
// .excludePathPatterns("/lpkgoods/vegeCellarList")
|
||||
|
// .excludePathPatterns("/customerstore/getStoreBySid/**")
|
||||
|
// .excludePathPatterns("/lpkgiftcard/bindAllCard")
|
||||
|
// .excludePathPatterns("/lpkcustomer/customerInfo/**")
|
||||
|
// .excludePathPatterns("/vegetablecellar/saveGoods")
|
||||
|
// .excludePathPatterns("/transferrecords/getTransferByCode/**")
|
||||
|
// //2024-01-18
|
||||
|
// .excludePathPatterns("/lpkcustomer/getCustomerInfo/**")
|
||||
|
// .excludePathPatterns("/lpkcustomer/modifyUserNickName")
|
||||
|
// .excludePathPatterns("/lpkcustomer/modifyHeadImage")
|
||||
|
// .excludePathPatterns("/upload/**")
|
||||
|
// .excludePathPatterns("/lpkcustomer/getPhoneNumber")
|
||||
|
// .excludePathPatterns("/lpkcustomer/getRealInfo/**")
|
||||
|
// .excludePathPatterns("/lpkcustomer/saveRealInfo")
|
||||
|
// .excludePathPatterns("/pms/PmsBrand/getList")
|
||||
|
// .excludePathPatterns("/LpkCustomerBank/getBankList")
|
||||
|
// .excludePathPatterns("/lpkcustomer/updateCustomerBank")
|
||||
|
// .excludePathPatterns("//wxapi/**")
|
||||
|
// ;
|
||||
|
// }
|
||||
|
//}
|
@ -0,0 +1,67 @@ |
|||||
|
package com.yxt.oms.config; |
||||
|
|
||||
|
import com.yxt.common.base.config.handler.GlobalExceptionHandler; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.validation.BindException; |
||||
|
import org.springframework.validation.ObjectError; |
||||
|
import org.springframework.web.bind.MethodArgumentNotValidException; |
||||
|
import org.springframework.web.bind.annotation.ExceptionHandler; |
||||
|
import org.springframework.web.bind.annotation.RestControllerAdvice; |
||||
|
import org.springframework.web.servlet.NoHandlerFoundException; |
||||
|
|
||||
|
/** |
||||
|
* @author dimengzhe |
||||
|
* @date 2020/9/12 3:23 |
||||
|
* @description 全局异常处理 |
||||
|
*/ |
||||
|
@RestControllerAdvice |
||||
|
public class SaTokenGloableException extends GlobalExceptionHandler { |
||||
|
|
||||
|
private static final Logger L = LoggerFactory.getLogger(GlobalExceptionHandler.class); |
||||
|
|
||||
|
public SaTokenGloableException() { |
||||
|
} |
||||
|
@ExceptionHandler({Exception.class}) |
||||
|
public ResultBean handleException(Exception e) { |
||||
|
if(null !=e.getMessage()){ |
||||
|
if(e.getMessage().contains("token 无效:")){ |
||||
|
L.error(e.getMessage(), e); |
||||
|
return ResultBean.fireFail().setCode("5000").setMsg("系统异常::" + e.getMessage()); |
||||
|
} |
||||
|
if(e.getMessage().contains("未能读取到有效 token")){ |
||||
|
// L.error(e.getMessage(), e);
|
||||
|
return ResultBean.fireFail().setMsg("系统异常::" + e.getMessage()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
L.error(e.getMessage(), e); |
||||
|
return ResultBean.fireFail().setMsg("系统异常::" + e.getMessage()); |
||||
|
} |
||||
|
@ExceptionHandler({NoHandlerFoundException.class}) |
||||
|
public ResultBean handlerNoFoundException(Exception e) { |
||||
|
L.error(e.getMessage(), e); |
||||
|
return ResultBean.fireFail().setCode("404").setMsg("路径不存在,请检查路径是否正确"); |
||||
|
} |
||||
|
|
||||
|
// @ExceptionHandler({Exception.class})
|
||||
|
// public ResultBean handleException(Exception e) {
|
||||
|
// L.error(e.getMessage(), e);
|
||||
|
// return ResultBean.fireFail().setMsg("系统异常::" + e.getMessage());
|
||||
|
// }
|
||||
|
|
||||
|
@ExceptionHandler({BindException.class}) |
||||
|
public ResultBean validatedBindException(BindException e) { |
||||
|
L.error(e.getMessage(), e); |
||||
|
String message = ((ObjectError)e.getAllErrors().get(0)).getDefaultMessage(); |
||||
|
return ResultBean.fireFail().setCode("405").setMsg(message); |
||||
|
} |
||||
|
|
||||
|
@ExceptionHandler({MethodArgumentNotValidException.class}) |
||||
|
public ResultBean validExceptionHandler(MethodArgumentNotValidException e) { |
||||
|
L.error(e.getMessage(), e); |
||||
|
String message = e.getBindingResult().getFieldError().getDefaultMessage(); |
||||
|
return ResultBean.fireFail().setCode("405").setMsg(message); |
||||
|
} |
||||
|
} |
@ -0,0 +1,4 @@ |
|||||
|
/** |
||||
|
* 宇信通监管项目-光伏(山海新能源)项目后台逻辑和接口-接口声明 |
||||
|
*/ |
||||
|
package com.yxt.oms.config; |
@ -0,0 +1,4 @@ |
|||||
|
/** |
||||
|
* 宇信通监管项目-光伏(山海新能源)项目后台逻辑和接口-接口声明 |
||||
|
*/ |
||||
|
package com.yxt.oms.feign; |
@ -0,0 +1,55 @@ |
|||||
|
package com.yxt.oms.feign.purchase.purchasereceiptbill; |
||||
|
|
||||
|
import com.yxt.common.core.query.PagerQuery; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import com.yxt.common.core.vo.PagerVo; |
||||
|
import com.yxt.oms.biz.func.purchasereceiptbill.PurchaseReceiptBill; |
||||
|
import com.yxt.oms.biz.func.purchasereceiptbill.PurchaseReceiptBillDto; |
||||
|
import com.yxt.oms.biz.func.purchasereceiptbill.PurchaseReceiptBillQuery; |
||||
|
import com.yxt.oms.biz.func.purchasereceiptbill.PurchaseReceiptBillVo; |
||||
|
import com.yxt.oms.feign.purchase.PurchaseReceiptBillFeignFallback; |
||||
|
import com.yxt.oms.utils.OrgPathQuery; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import org.springframework.cloud.openfeign.FeignClient; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: wangpengfei |
||||
|
* @date: 2024/4/12 |
||||
|
**/ |
||||
|
@FeignClient( |
||||
|
contextId = "ss-common-purchase-PurchaseReceiptBill", |
||||
|
name = "ss-common-purchase", |
||||
|
path = "/apiadmin/purchasereceiptbill", |
||||
|
fallback = PurchaseReceiptBillFeignFallback.class) |
||||
|
public interface PurchaseReceiptBillFeign { |
||||
|
|
||||
|
|
||||
|
@ApiOperation("分页列表") |
||||
|
@PostMapping("/listPage") |
||||
|
public ResultBean<PagerVo<PurchaseReceiptBillVo>> listPage(@RequestBody PagerQuery<PurchaseReceiptBillQuery> pq); |
||||
|
|
||||
|
@ApiOperation("保存修改") |
||||
|
@PostMapping("/saveOrUpdate") |
||||
|
public ResultBean<String> saveOrUpdate(@RequestBody PurchaseReceiptBillDto dto); |
||||
|
@ApiOperation("查询所有的品牌") |
||||
|
@PostMapping("/listAll") |
||||
|
public ResultBean<List<PurchaseReceiptBill>> listAll(@RequestBody OrgPathQuery query); |
||||
|
@ApiOperation("初始化") |
||||
|
@GetMapping("/initialization/{sid}") |
||||
|
public ResultBean<PurchaseReceiptBillVo> initialization(@PathVariable("sid") String sid); |
||||
|
|
||||
|
@ApiOperation("更改可用状态") |
||||
|
@GetMapping("/updateIsEnable/{sid}/{isEnable}") |
||||
|
public ResultBean updateIsEnable(@PathVariable("sid") String sid,@PathVariable("isEnable")String isEnable); |
||||
|
@ApiOperation("根据品牌名查询") |
||||
|
@GetMapping("/getBrandByName/{name}") |
||||
|
public ResultBean<PurchaseReceiptBill> getBrandByName(@PathVariable("name") String name); |
||||
|
@ApiOperation("根据sid批量删除") |
||||
|
@DeleteMapping("/delBySids") |
||||
|
public ResultBean delBySids(@RequestBody String[] sids); |
||||
|
|
||||
|
} |
@ -0,0 +1,59 @@ |
|||||
|
package com.yxt.oms.feign.purchase; |
||||
|
|
||||
|
import com.yxt.common.core.query.PagerQuery; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import com.yxt.common.core.vo.PagerVo; |
||||
|
import com.yxt.oms.biz.func.purchasereceiptbill.PurchaseReceiptBill; |
||||
|
import com.yxt.oms.biz.func.purchasereceiptbill.PurchaseReceiptBillDto; |
||||
|
import com.yxt.oms.biz.func.purchasereceiptbill.PurchaseReceiptBillQuery; |
||||
|
import com.yxt.oms.biz.func.purchasereceiptbill.PurchaseReceiptBillVo; |
||||
|
import com.yxt.oms.feign.purchase.purchasereceiptbill.PurchaseReceiptBillFeign; |
||||
|
import com.yxt.oms.utils.OrgPathQuery; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: dimengzhe |
||||
|
* @date: 2024/3/20 |
||||
|
**/ |
||||
|
@Component |
||||
|
public class PurchaseReceiptBillFeignFallback implements PurchaseReceiptBillFeign { |
||||
|
|
||||
|
@Override |
||||
|
public ResultBean<PagerVo<PurchaseReceiptBillVo>> listPage(PagerQuery<PurchaseReceiptBillQuery> pq) { |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public ResultBean<String> saveOrUpdate(PurchaseReceiptBillDto dto) { |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public ResultBean<List<PurchaseReceiptBill>> listAll(OrgPathQuery query) { |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public ResultBean<PurchaseReceiptBillVo> initialization(String sid) { |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public ResultBean updateIsEnable(String sid, String isEnable) { |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public ResultBean<PurchaseReceiptBill> getBrandByName(String name) { |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public ResultBean delBySids(String[] sids) { |
||||
|
return null; |
||||
|
} |
||||
|
} |
@ -0,0 +1,61 @@ |
|||||
|
package com.yxt.oms.feign.warehouse.warehouseansbill; |
||||
|
|
||||
|
import com.yxt.common.core.query.PagerQuery; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import com.yxt.common.core.vo.PagerVo; |
||||
|
import com.yxt.oms.biz.func.warehouseansbill.WarehouseAnsBillDto; |
||||
|
import com.yxt.oms.biz.func.warehouseansbill.WarehouseAnsBillQuery; |
||||
|
import com.yxt.oms.biz.func.warehouseansbill.WarehouseAnsBillVo; |
||||
|
import com.yxt.oms.biz.func.warehouseansbill.WarehouseAnsDetailsVo; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import org.springframework.cloud.openfeign.FeignClient; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
|
||||
|
/** |
||||
|
* Project: anrui_portal(门户建设) <br/> |
||||
|
* File: SysRoleFeign.java <br/> |
||||
|
* Class: com.yxt.anrui.portal.api.sysrole.SysRoleFeign <br/> |
||||
|
* Description: 角色. <br/> |
||||
|
* Copyright: Copyright (c) 2011 <br/> |
||||
|
* Company: https://gitee.com/liuzp315 <br/>
|
||||
|
* Makedate: 2021-08-03 00:24:29 <br/> |
||||
|
* |
||||
|
* @author liupopo |
||||
|
* @version 1.0 |
||||
|
* @since 1.0 |
||||
|
*/ |
||||
|
@Api(tags = "角色") |
||||
|
@FeignClient( |
||||
|
contextId = "ss-common-warehouse-WmsAnsBill", |
||||
|
name = "ss-common-warehouse", |
||||
|
path = "/apiadmin/warehouseansbill", |
||||
|
fallback = WarehouseAnsBillFeignFallback.class) |
||||
|
public interface WarehouseAnsBillFeign { |
||||
|
|
||||
|
@PostMapping("saveOrUpdate") |
||||
|
@ApiOperation("新增修改保存") |
||||
|
ResultBean<String> saveOrUpdate(@RequestBody WarehouseAnsBillDto dto); |
||||
|
@PostMapping("saveBill") |
||||
|
@ApiOperation("oms推送预期到货通知单") |
||||
|
ResultBean<String> saveBill(@RequestBody WarehouseAnsBillDto dto); |
||||
|
|
||||
|
/* @PostMapping("pageList") |
||||
|
@ApiOperation("收货单据选择") |
||||
|
ResultBean<PagerVo<WmsAnsBillDetailVo>> pageList(@RequestBody PagerQuery<WmsAnsBillDetailQuery> pagerQuery) { |
||||
|
ResultBean<PagerVo<WmsAnsBillDetailVo>> rb = ResultBean.fireFail(); |
||||
|
PagerVo<WmsAnsBillDetailVo> pv = wmsAnsBillService.listPage(pagerQuery); |
||||
|
return rb.success().setData(pv); |
||||
|
}*/ |
||||
|
|
||||
|
@PostMapping("listPage") |
||||
|
@ApiOperation("分页列表") |
||||
|
ResultBean<PagerVo<WarehouseAnsBillVo>> listPage(@RequestBody PagerQuery<WarehouseAnsBillQuery> pagerQuery); |
||||
|
|
||||
|
@GetMapping("details") |
||||
|
@ApiOperation("详情") |
||||
|
ResultBean<WarehouseAnsDetailsVo> details(@RequestParam("sid") String sid); |
||||
|
} |
@ -0,0 +1,48 @@ |
|||||
|
package com.yxt.oms.feign.warehouse.warehouseansbill; |
||||
|
|
||||
|
import com.yxt.common.core.query.PagerQuery; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import com.yxt.common.core.vo.PagerVo; |
||||
|
import com.yxt.oms.biz.func.warehouseansbill.WarehouseAnsBillDto; |
||||
|
import com.yxt.oms.biz.func.warehouseansbill.WarehouseAnsBillQuery; |
||||
|
import com.yxt.oms.biz.func.warehouseansbill.WarehouseAnsBillVo; |
||||
|
import com.yxt.oms.biz.func.warehouseansbill.WarehouseAnsDetailsVo; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* Project: anrui_portal(门户建设) <br/> |
||||
|
* File: SysRoleFeignFallback.java <br/> |
||||
|
* Class: com.yxt.anrui.portal.api.sysrole.SysRoleFeignFallback <br/> |
||||
|
* Description: 角色. <br/> |
||||
|
* Copyright: Copyright (c) 2011 <br/> |
||||
|
* Company: https://gitee.com/liuzp315 <br/>
|
||||
|
* Makedate: 2021-08-03 00:24:29 <br/> |
||||
|
* |
||||
|
* @author liupopo |
||||
|
* @version 1.0 |
||||
|
* @since 1.0 |
||||
|
*/ |
||||
|
@Component |
||||
|
public class WarehouseAnsBillFeignFallback implements WarehouseAnsBillFeign { |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public ResultBean<String> saveOrUpdate(WarehouseAnsBillDto dto) { |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public ResultBean<String> saveBill(WarehouseAnsBillDto dto) { |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public ResultBean<PagerVo<WarehouseAnsBillVo>> listPage(PagerQuery<WarehouseAnsBillQuery> pagerQuery) { |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public ResultBean<WarehouseAnsDetailsVo> details(String sid) { |
||||
|
return null; |
||||
|
} |
||||
|
} |
@ -0,0 +1,93 @@ |
|||||
|
package com.yxt.oms.utils; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2024/1/24 8:53 |
||||
|
*/ |
||||
|
public class DoubleUtils { |
||||
|
|
||||
|
/** |
||||
|
* 对double数据进行取精度. |
||||
|
* @param value double数据. |
||||
|
* @param scale 精度位数(保留的小数位数). |
||||
|
* @param roundingMode 精度取值方式. |
||||
|
* @return 精度计算后的数据. |
||||
|
*/ |
||||
|
public static double round(double value, int scale, |
||||
|
int roundingMode) { |
||||
|
BigDecimal bd = BigDecimal.valueOf(value); |
||||
|
bd = bd.setScale(scale, roundingMode); |
||||
|
double d = bd.doubleValue(); |
||||
|
bd = null; |
||||
|
return d; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* double 相加 |
||||
|
* @param d1 |
||||
|
* @param d2 |
||||
|
* @return |
||||
|
*/ |
||||
|
public static double sum(double d1,double d2){ |
||||
|
BigDecimal bd1 = BigDecimal.valueOf(d1); |
||||
|
BigDecimal bd2 = BigDecimal.valueOf(d2); |
||||
|
return bd1.add(bd2).doubleValue(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* double 相减 |
||||
|
* @param d1 |
||||
|
* @param d2 |
||||
|
* @return |
||||
|
*/ |
||||
|
public static double sub(double d1,double d2){ |
||||
|
BigDecimal bd1 = BigDecimal.valueOf(d1); |
||||
|
BigDecimal bd2 = BigDecimal.valueOf(d2); |
||||
|
return bd1.subtract(bd2).doubleValue(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* double 乘法 |
||||
|
* @param d1 |
||||
|
* @param d2 |
||||
|
* @return |
||||
|
*/ |
||||
|
public static double mul(double d1, double d2){ |
||||
|
BigDecimal bd1 = BigDecimal.valueOf(d1); |
||||
|
BigDecimal bd2 = BigDecimal.valueOf(d2); |
||||
|
return bd1.multiply(bd2).doubleValue(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* double 除法 |
||||
|
* @param d1 |
||||
|
* @param d2 |
||||
|
* @param scale 四舍五入 小数点位数 |
||||
|
* @return |
||||
|
*/ |
||||
|
public static double div(double d1,double d2,int scale){ |
||||
|
BigDecimal bd1 = BigDecimal.valueOf(d1); |
||||
|
BigDecimal bd2 = BigDecimal.valueOf(d2); |
||||
|
return bd1.divide |
||||
|
(bd2,scale,BigDecimal.ROUND_HALF_UP).doubleValue(); |
||||
|
} |
||||
|
/** |
||||
|
* 去除多余.0 |
||||
|
* @param num |
||||
|
* @return |
||||
|
*/ |
||||
|
public static String removeZeros(String num) { |
||||
|
if (num.indexOf(".") > 0) { |
||||
|
// 去掉多余的0
|
||||
|
num = num.replaceAll("0+?$", ""); |
||||
|
// 如果最后一位是. 则去掉
|
||||
|
num = num.replaceAll("[.]$", ""); |
||||
|
} |
||||
|
return num; |
||||
|
} |
||||
|
} |
@ -0,0 +1,171 @@ |
|||||
|
package com.yxt.oms.utils; |
||||
|
|
||||
|
|
||||
|
//import org.apache.log4j.Logger;
|
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
||||
|
import org.apache.poi.ss.usermodel.Cell; |
||||
|
import org.apache.poi.ss.usermodel.Row; |
||||
|
import org.apache.poi.ss.usermodel.Sheet; |
||||
|
import org.apache.poi.ss.usermodel.Workbook; |
||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import java.io.FileNotFoundException; |
||||
|
import java.io.IOException; |
||||
|
import java.io.InputStream; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
import static org.apache.poi.ss.usermodel.CellType.NUMERIC; |
||||
|
import static org.apache.poi.ss.usermodel.CellType.STRING; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2024/4/23 13:53 |
||||
|
*/ |
||||
|
public class ExcelUtil { |
||||
|
// private static Logger logger = Logger.getLogger(ExcelUtil.class);
|
||||
|
private final static String xls = "xls"; |
||||
|
private final static String xlsx = "xlsx"; |
||||
|
|
||||
|
/** |
||||
|
* 读入excel文件,解析后返回 |
||||
|
* |
||||
|
* @param file |
||||
|
* @throws IOException |
||||
|
*/ |
||||
|
public static List<String[]> readExcel(MultipartFile file) throws IOException { |
||||
|
//检查文件
|
||||
|
checkFile(file); |
||||
|
//获得Workbook工作薄对象
|
||||
|
Workbook workbook = getWorkBook(file); |
||||
|
//创建返回对象,把每行中的值作为一个数组,所有行作为一个集合返回
|
||||
|
List<String[]> list = new ArrayList<String[]>(); |
||||
|
if (workbook != null) { |
||||
|
for (int sheetNum = 0; sheetNum < workbook.getNumberOfSheets(); sheetNum++) { |
||||
|
//获得当前sheet工作表
|
||||
|
Sheet sheet = workbook.getSheetAt(sheetNum); |
||||
|
if (sheet == null) { |
||||
|
continue; |
||||
|
} |
||||
|
//获得当前sheet的开始行
|
||||
|
int firstRowNum = sheet.getFirstRowNum(); |
||||
|
//获得当前sheet的结束行
|
||||
|
int lastRowNum = sheet.getLastRowNum(); |
||||
|
int arrLength = sheet.getRow(firstRowNum).getPhysicalNumberOfCells(); |
||||
|
int rowNumb=firstRowNum + 1; |
||||
|
//循环除了第一行的所有行
|
||||
|
for (int rowNum = rowNumb; rowNum <= lastRowNum; rowNum++) { |
||||
|
//获得当前行
|
||||
|
Row row = sheet.getRow(rowNum); |
||||
|
if (row == null) { |
||||
|
continue; |
||||
|
} |
||||
|
//获得当前行的开始列
|
||||
|
int firstCellNum = row.getFirstCellNum(); |
||||
|
//获得当前行的列数
|
||||
|
int lastCellNum = row.getPhysicalNumberOfCells(); |
||||
|
String[] cells = new String[arrLength]; |
||||
|
//循环当前行
|
||||
|
for(int i =0 ;i<arrLength;i++){ Cell cell = row.getCell(i);cells[i] = getCellValue(cell); } |
||||
|
list.add(cells); |
||||
|
} |
||||
|
} |
||||
|
workbook.close(); |
||||
|
} |
||||
|
return list; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 检查文件 |
||||
|
* |
||||
|
* @param file |
||||
|
* @throws IOException |
||||
|
*/ |
||||
|
public static void checkFile(MultipartFile file) throws IOException { |
||||
|
ResultBean rb=new ResultBean().fail(); |
||||
|
//判断文件是否存在
|
||||
|
if (null == file) { |
||||
|
throw new FileNotFoundException("文件不存在!"); |
||||
|
} |
||||
|
//获得文件名
|
||||
|
String fileName = file.getOriginalFilename(); |
||||
|
//判断文件是否是excel文件
|
||||
|
if (!fileName.endsWith(xls) && !fileName.endsWith(xlsx)) { |
||||
|
// logger.error(fileName + "不是excel文件");
|
||||
|
throw new IOException(fileName + "不是excel文件"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 返回工作簿 |
||||
|
* |
||||
|
* @param file |
||||
|
* @return |
||||
|
*/ |
||||
|
public static Workbook getWorkBook(MultipartFile file) { |
||||
|
//获得文件名
|
||||
|
String fileName = file.getOriginalFilename(); |
||||
|
//创建Workbook工作薄对象,表示整个excel
|
||||
|
Workbook workbook = null; |
||||
|
try { |
||||
|
//获取excel文件的io流
|
||||
|
InputStream is = file.getInputStream(); |
||||
|
//根据文件后缀名不同(xls和xlsx)获得不同的Workbook实现类对象
|
||||
|
if (fileName.endsWith(xls)) { |
||||
|
//2003
|
||||
|
workbook = new HSSFWorkbook(is); |
||||
|
} else if (fileName.endsWith(xlsx)) { |
||||
|
//2007
|
||||
|
workbook = new XSSFWorkbook(is); |
||||
|
} |
||||
|
} catch (IOException e) { |
||||
|
// logger.info(e.getMessage());
|
||||
|
} |
||||
|
return workbook; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 处理单元格样式 获取数据 |
||||
|
* |
||||
|
* @param cell |
||||
|
* @return |
||||
|
*/ |
||||
|
public static String getCellValue(Cell cell) { |
||||
|
String cellValue = ""; |
||||
|
if (cell == null) { |
||||
|
return cellValue; |
||||
|
} |
||||
|
//把数字当成String来读,避免出现1读成1.0的情况
|
||||
|
if (cell.getCellType() == NUMERIC) { |
||||
|
cell.setCellType(STRING); |
||||
|
} |
||||
|
//判断数据的类型
|
||||
|
switch (cell.getCellType()) { |
||||
|
case NUMERIC: //数字
|
||||
|
cellValue = String.valueOf(cell.getNumericCellValue()); |
||||
|
break; |
||||
|
case STRING: //字符串
|
||||
|
cellValue = String.valueOf(cell.getStringCellValue()); |
||||
|
break; |
||||
|
case BOOLEAN: //Boolean
|
||||
|
cellValue = String.valueOf(cell.getBooleanCellValue()); |
||||
|
break; |
||||
|
case FORMULA: //公式
|
||||
|
cellValue = String.valueOf(cell.getCellFormula()); |
||||
|
break; |
||||
|
case BLANK: //空值
|
||||
|
cellValue = ""; |
||||
|
break; |
||||
|
case ERROR: //故障
|
||||
|
cellValue = "非法字符"; |
||||
|
break; |
||||
|
default: |
||||
|
cellValue = "未知类型"; |
||||
|
break; |
||||
|
} |
||||
|
return cellValue; |
||||
|
} |
||||
|
} |
@ -0,0 +1,14 @@ |
|||||
|
package com.yxt.oms.utils; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author Fan |
||||
|
* @description |
||||
|
* @date 2024/5/17 14:15 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class OrgPathQuery { |
||||
|
private String orgPath; |
||||
|
private String userOrgSid; |
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
package com.yxt.oms.utils; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: dimengzhe |
||||
|
* @date: 2024/3/20 |
||||
|
**/ |
||||
|
public class Rule { |
||||
|
|
||||
|
public static String getBillNo(String bill, int i) { |
||||
|
String num = String.format("%04d", i + 1); // 不足4位补0
|
||||
|
String billNo = bill + num; |
||||
|
return billNo; |
||||
|
} |
||||
|
} |
@ -0,0 +1,90 @@ |
|||||
|
package com.yxt.oms.utils; |
||||
|
|
||||
|
|
||||
|
import com.alibaba.excel.write.metadata.style.WriteCellStyle; |
||||
|
import com.alibaba.excel.write.metadata.style.WriteFont; |
||||
|
import org.apache.poi.ss.usermodel.BorderStyle; |
||||
|
import org.apache.poi.ss.usermodel.HorizontalAlignment; |
||||
|
import org.apache.poi.ss.usermodel.VerticalAlignment; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/12/16 22:14 |
||||
|
*/ |
||||
|
public class StyleUtils { /** |
||||
|
* 标题样式 |
||||
|
* @return |
||||
|
*/ |
||||
|
public static WriteCellStyle getHeadStyle(){ |
||||
|
// 头的策略
|
||||
|
WriteCellStyle headWriteCellStyle = new WriteCellStyle(); |
||||
|
// 背景颜色
|
||||
|
// headWriteCellStyle.setFillForegroundColor(IndexedColors.LIGHT_TURQUOISE1.getIndex());
|
||||
|
// headWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);
|
||||
|
|
||||
|
// 字体
|
||||
|
WriteFont headWriteFont = new WriteFont(); |
||||
|
headWriteFont.setFontName("宋体");//设置字体名字
|
||||
|
headWriteFont.setFontHeightInPoints((short)14);//设置字体大小
|
||||
|
headWriteFont.setBold(true);//字体加粗
|
||||
|
headWriteCellStyle.setWriteFont(headWriteFont); //在样式用应用设置的字体;
|
||||
|
|
||||
|
// 样式
|
||||
|
headWriteCellStyle.setBorderBottom(BorderStyle.THIN);//设置底边框;
|
||||
|
headWriteCellStyle.setBottomBorderColor((short) 0);//设置底边框颜色;
|
||||
|
headWriteCellStyle.setBorderLeft(BorderStyle.THIN); //设置左边框;
|
||||
|
headWriteCellStyle.setLeftBorderColor((short) 0);//设置左边框颜色;
|
||||
|
headWriteCellStyle.setBorderRight(BorderStyle.THIN);//设置右边框;
|
||||
|
headWriteCellStyle.setRightBorderColor((short) 0);//设置右边框颜色;
|
||||
|
headWriteCellStyle.setBorderTop(BorderStyle.THIN);//设置顶边框;
|
||||
|
headWriteCellStyle.setTopBorderColor((short) 0); //设置顶边框颜色;
|
||||
|
|
||||
|
headWriteCellStyle.setWrapped(true); //设置自动换行;
|
||||
|
|
||||
|
headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);//设置水平对齐的样式为居中对齐;
|
||||
|
headWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); //设置垂直对齐的样式为居中对齐;
|
||||
|
headWriteCellStyle.setShrinkToFit(true);//设置文本收缩至合适
|
||||
|
|
||||
|
return headWriteCellStyle; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 内容样式 |
||||
|
* @return |
||||
|
*/ |
||||
|
public static WriteCellStyle getContentStyle(){ |
||||
|
// 内容的策略
|
||||
|
WriteCellStyle contentWriteCellStyle = new WriteCellStyle(); |
||||
|
|
||||
|
// 背景绿色
|
||||
|
// 这里需要指定 FillPatternType 为FillPatternType.SOLID_FOREGROUND 不然无法显示背景颜色.头默认了 FillPatternType所以可以不指定
|
||||
|
// contentWriteCellStyle.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex());
|
||||
|
// contentWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);
|
||||
|
|
||||
|
// 设置字体
|
||||
|
WriteFont contentWriteFont = new WriteFont(); |
||||
|
contentWriteFont.setFontHeightInPoints((short) 12);//设置字体大小
|
||||
|
contentWriteFont.setFontName("宋体"); //设置字体名字
|
||||
|
contentWriteCellStyle.setWriteFont(contentWriteFont);//在样式用应用设置的字体;
|
||||
|
|
||||
|
//设置样式;
|
||||
|
contentWriteCellStyle.setBorderBottom(BorderStyle.THIN);//设置底边框;
|
||||
|
contentWriteCellStyle.setBottomBorderColor((short) 0);//设置底边框颜色;
|
||||
|
contentWriteCellStyle.setBorderLeft(BorderStyle.THIN); //设置左边框;
|
||||
|
contentWriteCellStyle.setLeftBorderColor((short) 0);//设置左边框颜色;
|
||||
|
contentWriteCellStyle.setBorderRight(BorderStyle.THIN);//设置右边框;
|
||||
|
contentWriteCellStyle.setRightBorderColor((short) 0);//设置右边框颜色;
|
||||
|
contentWriteCellStyle.setBorderTop(BorderStyle.THIN);//设置顶边框;
|
||||
|
contentWriteCellStyle.setTopBorderColor((short) 0); ///设置顶边框颜色;
|
||||
|
|
||||
|
contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);// 水平居中
|
||||
|
contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 垂直居中
|
||||
|
contentWriteCellStyle.setWrapped(true); //设置自动换行;
|
||||
|
|
||||
|
// contentWriteCellStyle.setShrinkToFit(true);//设置文本收缩至合适
|
||||
|
|
||||
|
return contentWriteCellStyle; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
spring: |
||||
|
datasource: |
||||
|
driver-class-name: com.mysql.cj.jdbc.Driver |
||||
|
url: jdbc:mysql://39.104.100.138:3306/yxt_wms?serverTimezone=GMT%2B8&autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&nullCatalogMeansCurrent=true |
||||
|
username: root |
||||
|
password: yxt_mysql_138 |
||||
|
cloud: |
||||
|
nacos: |
||||
|
discovery: |
||||
|
# namespace: supervise |
||||
|
server-addr: 127.0.0.1:8848 |
||||
|
redis: |
||||
|
database: 4 # Redis数据库索引(默认为0) |
||||
|
host: 127.0.0.1 |
||||
|
jedis: |
||||
|
pool: |
||||
|
max-active: -1 #连接池最大连接数(使用负值表示没有限制) |
||||
|
max-idle: 8 #连接池中的最大空闲连接 |
||||
|
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制) |
||||
|
min-idle: 0 # 连接池中的最小空闲连接 |
||||
|
password: |
||||
|
port: 6379 |
||||
|
timeout: 0 # 连接超时时间(毫秒) |
||||
|
|
||||
|
image: |
||||
|
upload: |
||||
|
path: D:\sharestore\upload\ |
||||
|
url: |
||||
|
prefix: D:/project/yxtt/share-store/share-store/wms-biz/target/static/uploda/ |
@ -0,0 +1,29 @@ |
|||||
|
spring: |
||||
|
datasource: |
||||
|
driver-class-name: com.mysql.cj.jdbc.Driver |
||||
|
url: jdbc:mysql://8.130.39.13:3306/ss_goods?serverTimezone=GMT%2B8&autoReconnect=true&useUnicode=true&characterEncoding=UTF-8 |
||||
|
username: root |
||||
|
password: 1LAiGz$t1*Iw |
||||
|
cloud: |
||||
|
nacos: |
||||
|
discovery: |
||||
|
# namespace: supervise |
||||
|
server-addr: 127.0.0.1:8848 |
||||
|
redis: |
||||
|
database: 4 # Redis数据库索引(默认为0) |
||||
|
host: 127.0.0.1 |
||||
|
jedis: |
||||
|
pool: |
||||
|
max-active: -1 #连接池最大连接数(使用负值表示没有限制) |
||||
|
max-idle: 8 #连接池中的最大空闲连接 |
||||
|
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制) |
||||
|
min-idle: 0 # 连接池中的最小空闲连接 |
||||
|
password: 123456 |
||||
|
port: 6379 |
||||
|
timeout: 0 # 连接超时时间(毫秒) |
||||
|
|
||||
|
image: |
||||
|
upload: |
||||
|
path: D:/webapps/share-store/ui/share-store-ui/static/upload/ |
||||
|
url: |
||||
|
prefix: https://wms.yxtsoft.com/static/upload/ |
@ -0,0 +1,29 @@ |
|||||
|
spring: |
||||
|
datasource: |
||||
|
driver-class-name: com.mysql.cj.jdbc.Driver |
||||
|
url: jdbc:mysql://39.104.100.138:3306/yxt_wms?serverTimezone=GMT%2B8&autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&nullCatalogMeansCurrent=true |
||||
|
username: root |
||||
|
password: yxt_mysql_138 |
||||
|
cloud: |
||||
|
nacos: |
||||
|
discovery: |
||||
|
server-addr: 39.104.100.138:8848 |
||||
|
redis: |
||||
|
database: 4 # Redis数据库索引(默认为0) |
||||
|
host: 127.0.0.1 |
||||
|
jedis: |
||||
|
pool: |
||||
|
max-active: -1 #连接池最大连接数(使用负值表示没有限制) |
||||
|
max-idle: 8 #连接池中的最大空闲连接 |
||||
|
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制) |
||||
|
min-idle: 0 # 连接池中的最小空闲连接 |
||||
|
password: 123456 |
||||
|
port: 6379 |
||||
|
timeout: 0 # 连接超时时间(毫秒) |
||||
|
|
||||
|
image: |
||||
|
upload: |
||||
|
path: /home/lzh/docker_data/nginx/html/share-store-ui/upload/ |
||||
|
url: |
||||
|
prefix: http://anrui.yyundong.com/upload/ |
||||
|
|
@ -0,0 +1,63 @@ |
|||||
|
spring: |
||||
|
application: |
||||
|
name: oms-biz |
||||
|
profiles: |
||||
|
active: dev |
||||
|
# active: pro |
||||
|
messages: |
||||
|
# 国际化资源文件路径 |
||||
|
basename: i18n/messages |
||||
|
servlet: |
||||
|
#上传文件 |
||||
|
multipart: |
||||
|
max-file-size: 50MB |
||||
|
max-request-size: 100MB |
||||
|
devtools: |
||||
|
restart: |
||||
|
# 热部署开关 |
||||
|
enabled: true |
||||
|
mvc: |
||||
|
async: |
||||
|
request-timeout: 20000 |
||||
|
|
||||
|
|
||||
|
|
||||
|
server: |
||||
|
port: 6022 |
||||
|
max-http-header-size: 102400 |
||||
|
tomcat: |
||||
|
max-http-form-post-size: -1 |
||||
|
#mybatis |
||||
|
mybatis-plus: |
||||
|
# 配置mapper的扫描,找到所有的mapper.xml映射文件 |
||||
|
mapper-locations: classpath*:**Mapper.xml |
||||
|
global-config: |
||||
|
refresh: true |
||||
|
db-config: |
||||
|
#定义生成ID的类型 |
||||
|
id-type: Auto |
||||
|
db-type: mysql |
||||
|
configuration: |
||||
|
map-underscore-to-camel-case: false |
||||
|
cache-enabled: true |
||||
|
call-setters-on-nulls: true |
||||
|
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl |
||||
|
|
||||
|
#hystrix的超时时间 |
||||
|
hystrix: |
||||
|
command: |
||||
|
default: |
||||
|
execution: |
||||
|
timeout: |
||||
|
enabled: true |
||||
|
isolation: |
||||
|
thread: |
||||
|
timeoutInMilliseconds: 60000 |
||||
|
#ribbon的超时时间 |
||||
|
ribbon: |
||||
|
ReadTimeout: 60000 |
||||
|
ConnectTimeout: 60000 |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
@ -0,0 +1,13 @@ |
|||||
|
,----.. ____ |
||||
|
/ / \ ,' , `. |
||||
|
| : : ,---. ,-+-,.' _ | ,---. ,---, |
||||
|
. | ;. / ' ,'\ ,-+-. ; , || ' ,'\ ,-+-. / | |
||||
|
. ; /--` / / | ,--.'|' | || ,---. / / | ,--.'|' | |
||||
|
; | ; . ; ,. :| | ,', | |,/ \ . ; ,. :| | ,"' | |
||||
|
| : | ' | |: :| | / | |--'/ / | ' | |: :| | / | | |
||||
|
. | '___' | .; :| : | | , . ' / | ' | .; :| | | | | |
||||
|
' ; : .'| : || : | |/ ' ; /| | : || | | |/ |
||||
|
' | '/ :\ \ / | | |`-' ' | / | \ \ / | | |--' |
||||
|
| : / `----' | ;/ | : | `----' | |/ |
||||
|
\ \ .' '---' \ \ / '---' |
||||
|
`---` `----' |
@ -0,0 +1,51 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<configuration> |
||||
|
|
||||
|
<property name="log.base" value="logs/ss-wms"/> |
||||
|
|
||||
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> |
||||
|
<encoder> |
||||
|
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 : |
||||
|
|%blue(%thread) 线程 如 :DiscoveryClient-CacheRefreshExecutor-0--> |
||||
|
<!--<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>--> |
||||
|
<pattern>%yellow(%date{yyyy-MM-dd HH:mm:ss}) |%highlight(%-5level) |%green(%logger:%line) |%blue(%msg%n) |
||||
|
</pattern> |
||||
|
</encoder> |
||||
|
</appender> |
||||
|
|
||||
|
<!-- 彩色日志 --> |
||||
|
<!-- 彩色日志依赖的渲染类 --> |
||||
|
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/> |
||||
|
<conversionRule conversionWord="wex" |
||||
|
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/> |
||||
|
<conversionRule conversionWord="wEx" |
||||
|
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/> |
||||
|
<!-- 彩色日志格式 --> |
||||
|
<property name="CONSOLE_LOG_PATTERN" |
||||
|
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/> |
||||
|
|
||||
|
<appender name="FILEOUT" |
||||
|
class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
|
<file>${log.base}.log</file> |
||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||
|
<fileNamePattern>${log.base}.%d{yyyyMMdd}.%i.log.zip |
||||
|
</fileNamePattern> |
||||
|
<!-- 当文件大小超过10MB时触发滚动 --> |
||||
|
<timeBasedFileNamingAndTriggeringPolicy |
||||
|
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
||||
|
<maxFileSize>1MB</maxFileSize> |
||||
|
</timeBasedFileNamingAndTriggeringPolicy> |
||||
|
</rollingPolicy> |
||||
|
<encoder> |
||||
|
<Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} |
||||
|
-%msg%n |
||||
|
</Pattern> |
||||
|
</encoder> |
||||
|
</appender> |
||||
|
|
||||
|
<root level="INFO"> |
||||
|
<appender-ref ref="STDOUT"/> |
||||
|
<appender-ref ref="FILEOUT"/> |
||||
|
</root> |
||||
|
|
||||
|
</configuration> |
@ -0,0 +1,404 @@ |
|||||
|
<?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"> |
||||
|
<modelVersion>4.0.0</modelVersion> |
||||
|
|
||||
|
<groupId>com.yxt</groupId> |
||||
|
<artifactId>oms-biz</artifactId> |
||||
|
<packaging>pom</packaging> |
||||
|
<version>1.0-SNAPSHOT</version> |
||||
|
<modules> |
||||
|
<module>gateway</module> |
||||
|
<module>oms</module> |
||||
|
</modules> |
||||
|
|
||||
|
|
||||
|
<properties> |
||||
|
<!-- 使用的JAVA版本号 --> |
||||
|
<java.version>1.8</java.version> |
||||
|
<!-- 项目构建编码 --> |
||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
||||
|
<!-- 项目输出编码 --> |
||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> |
||||
|
<maven.compiler.source>1.8</maven.compiler.source> |
||||
|
<maven.compiler.target>1.8</maven.compiler.target> |
||||
|
|
||||
|
<!-- Spring相关组件 --> |
||||
|
<!-- SpringBoot 依赖配置 --> |
||||
|
<spring-boot.version>2.2.9.RELEASE</spring-boot.version> |
||||
|
<!-- SpringCloud 微服务 --> |
||||
|
<spring-cloud.version>Hoxton.SR6</spring-cloud.version> |
||||
|
<!-- SpringCloud Alibaba 微服务 --> |
||||
|
<spring-cloud-alibaba.version>2.2.1.RELEASE</spring-cloud-alibaba.version> |
||||
|
<!-- nacos客户端 --> |
||||
|
<nacos.version>1.3.0</nacos.version> |
||||
|
|
||||
|
<!-- 公共的基础组件 --> |
||||
|
<!-- io常用工具类 --> |
||||
|
<commons.io.version>2.5</commons.io.version> |
||||
|
<commons-codec.version>1.14</commons-codec.version> |
||||
|
<!--Bean工具 --> |
||||
|
<commons.beanutils.version>1.9.3</commons.beanutils.version> |
||||
|
<!-- 线程池工具 --> |
||||
|
<common-pool.version>2.6.2</common-pool.version> |
||||
|
<!-- mybatis,mybatis-plus已经引用 |
||||
|
<spring-boot.mybatis>2.1.2</spring-boot.mybatis>--> |
||||
|
<!-- mybatis-plus --> |
||||
|
<mybatis-plus.version>3.4.0</mybatis-plus.version> |
||||
|
<!-- JSON 解析器和生成器 --> |
||||
|
<fastjson.version>1.2.73</fastjson.version> |
||||
|
<!--Token生成与解析 --> |
||||
|
<jjwt.version>0.9.1</jjwt.version> |
||||
|
|
||||
|
<!-- 辅助组件 --> |
||||
|
<!-- Swagger 依赖配置 --> |
||||
|
<swagger.fox.version>2.9.2</swagger.fox.version> |
||||
|
<knife4j-Swagger>2.0.5</knife4j-Swagger> |
||||
|
<!-- excel工具 --> |
||||
|
<poi.version>3.17</poi.version> |
||||
|
<!-- 验证码 --> |
||||
|
<kaptcha.version>2.3.2</kaptcha.version> |
||||
|
<!-- 解析客户端操作系统、浏览器等 --> |
||||
|
<bitwalker.version>1.19</bitwalker.version> |
||||
|
<!-- velocity模板引擎 --> |
||||
|
<velocity.version>1.7</velocity.version> |
||||
|
<!-- Hutool组件 --> |
||||
|
<hutool.version>5.4.0</hutool.version> |
||||
|
<hibernate-validator.version>6.0.20.Final</hibernate-validator.version> |
||||
|
<lombok.version>1.18.24</lombok.version> |
||||
|
<jedis.version>3.1.0</jedis.version> |
||||
|
<java-jwt.version>3.10.1</java-jwt.version> |
||||
|
<redis.version>2.2.9.RELEASE</redis.version> |
||||
|
<poi-tl.version>1.8.1</poi-tl.version> |
||||
|
<poi.version>4.1.2</poi.version> |
||||
|
<flowable.version>6.5.0</flowable.version> |
||||
|
<pdfbox.version>2.0.25</pdfbox.version> |
||||
|
</properties> |
||||
|
|
||||
|
<!-- 依赖声明 --> |
||||
|
<dependencyManagement> |
||||
|
<dependencies> |
||||
|
<!-- SpringBoot 依赖配置 --> |
||||
|
<dependency> |
||||
|
<groupId>org.springframework.boot</groupId> |
||||
|
<artifactId>spring-boot-dependencies</artifactId> |
||||
|
<version>${spring-boot.version}</version> |
||||
|
<type>pom</type> |
||||
|
<scope>import</scope> |
||||
|
</dependency> |
||||
|
<!-- SpringCloud 微服务 --> |
||||
|
<dependency> |
||||
|
<groupId>org.springframework.cloud</groupId> |
||||
|
<artifactId>spring-cloud-dependencies</artifactId> |
||||
|
<version>${spring-cloud.version}</version> |
||||
|
<type>pom</type> |
||||
|
<scope>import</scope> |
||||
|
</dependency> |
||||
|
<!-- SpringCloud Alibaba 微服务 --> |
||||
|
<dependency> |
||||
|
<groupId>com.alibaba.cloud</groupId> |
||||
|
<artifactId>spring-cloud-alibaba-dependencies</artifactId> |
||||
|
<version>${spring-cloud-alibaba.version}</version> |
||||
|
<type>pom</type> |
||||
|
<scope>import</scope> |
||||
|
</dependency> |
||||
|
<!-- Alibaba Nacos 配置 --> |
||||
|
<dependency> |
||||
|
<groupId>com.alibaba.nacos</groupId> |
||||
|
<artifactId>nacos-client</artifactId> |
||||
|
<version>${nacos.version}</version> |
||||
|
</dependency> |
||||
|
<!--Redis配置--> |
||||
|
<dependency> |
||||
|
<groupId>org.springframework.boot</groupId> |
||||
|
<artifactId>spring-boot-starter-data-redis</artifactId> |
||||
|
<version>${redis.version}</version> |
||||
|
<exclusions> |
||||
|
<exclusion> |
||||
|
<groupId>io.lettuce</groupId> |
||||
|
<artifactId>lettuce-core</artifactId> |
||||
|
</exclusion> |
||||
|
</exclusions> |
||||
|
</dependency> |
||||
|
<!-- https://mvnrepository.com/artifact/com.auth0/java-jwt --> |
||||
|
<dependency> |
||||
|
<groupId>com.auth0</groupId> |
||||
|
<artifactId>java-jwt</artifactId> |
||||
|
<version>${java-jwt.version}</version> |
||||
|
</dependency> |
||||
|
<!-- https://mvnrepository.com/artifact/redis.clients/jedis --> |
||||
|
<dependency> |
||||
|
<groupId>redis.clients</groupId> |
||||
|
<artifactId>jedis</artifactId> |
||||
|
<version>${jedis.version}</version> |
||||
|
</dependency> |
||||
|
<!-- io常用工具类 --> |
||||
|
<dependency> |
||||
|
<groupId>commons-io</groupId> |
||||
|
<artifactId>commons-io</artifactId> |
||||
|
<version>${commons.io.version}</version> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>commons-codec</groupId> |
||||
|
<artifactId>commons-codec</artifactId> |
||||
|
<version>${commons-codec.version}</version> |
||||
|
</dependency> |
||||
|
<!--Bean工具 --> |
||||
|
<dependency> |
||||
|
<groupId>commons-beanutils</groupId> |
||||
|
<artifactId>commons-beanutils</artifactId> |
||||
|
<version>${commons.beanutils.version}</version> |
||||
|
</dependency> |
||||
|
<!-- 公共资源池 --> |
||||
|
<dependency> |
||||
|
<groupId>org.apache.commons</groupId> |
||||
|
<artifactId>commons-pool2</artifactId> |
||||
|
<version>${common-pool.version}</version> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>com.baomidou</groupId> |
||||
|
<artifactId>mybatis-plus-boot-starter</artifactId> |
||||
|
<version>${mybatis-plus.version}</version> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>com.baomidou</groupId> |
||||
|
<artifactId>mybatis-plus-annotation</artifactId> |
||||
|
<version>${mybatis-plus.version}</version> |
||||
|
</dependency> |
||||
|
<!-- JSON 解析器和生成器 --> |
||||
|
<dependency> |
||||
|
<groupId>com.alibaba</groupId> |
||||
|
<artifactId>fastjson</artifactId> |
||||
|
<version>${fastjson.version}</version> |
||||
|
</dependency> |
||||
|
<!--Token生成与解析 --> |
||||
|
<dependency> |
||||
|
<groupId>io.jsonwebtoken</groupId> |
||||
|
<artifactId>jjwt</artifactId> |
||||
|
<version>${jjwt.version}</version> |
||||
|
</dependency> |
||||
|
|
||||
|
<!-- Swagger 依赖配置 --> |
||||
|
<dependency> |
||||
|
<groupId>io.springfox</groupId> |
||||
|
<artifactId>springfox-swagger2</artifactId> |
||||
|
<version>${swagger.fox.version}</version> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>io.springfox</groupId> |
||||
|
<artifactId>springfox-swagger-ui</artifactId> |
||||
|
<version>${swagger.fox.version}</version> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>com.github.xiaoymin</groupId> |
||||
|
<artifactId>knife4j-dependencies</artifactId> |
||||
|
<version>${knife4j-Swagger}</version> |
||||
|
<type>pom</type> |
||||
|
<scope>import</scope> |
||||
|
</dependency> |
||||
|
<!-- excel工具 --> |
||||
|
<dependency> |
||||
|
<groupId>org.apache.poi</groupId> |
||||
|
<artifactId>poi-ooxml</artifactId> |
||||
|
<version>${poi.version}</version> |
||||
|
</dependency> |
||||
|
<!-- 验证码 --> |
||||
|
<dependency> |
||||
|
<groupId>com.github.penggle</groupId> |
||||
|
<artifactId>kaptcha</artifactId> |
||||
|
<version>${kaptcha.version}</version> |
||||
|
</dependency> |
||||
|
<!-- 解析客户端操作系统、浏览器等 --> |
||||
|
<dependency> |
||||
|
<groupId>eu.bitwalker</groupId> |
||||
|
<artifactId>UserAgentUtils</artifactId> |
||||
|
<version>${bitwalker.version}</version> |
||||
|
</dependency> |
||||
|
<!-- 代码生成使用模板 --> |
||||
|
<dependency> |
||||
|
<groupId>org.apache.velocity</groupId> |
||||
|
<artifactId>velocity</artifactId> |
||||
|
<version>${velocity.version}</version> |
||||
|
</dependency> |
||||
|
|
||||
|
<!-- hutool所有模块 --> |
||||
|
<dependency> |
||||
|
<groupId>cn.hutool</groupId> |
||||
|
<artifactId>hutool-all</artifactId> |
||||
|
<version>${hutool.version}</version> |
||||
|
</dependency> |
||||
|
<!-- hutool 核心,包括Bean操作、日期、各种Util等 --> |
||||
|
<dependency> |
||||
|
<groupId>cn.hutool</groupId> |
||||
|
<artifactId>hutool-core</artifactId> |
||||
|
<version>${hutool.version}</version> |
||||
|
</dependency> |
||||
|
<!-- hutool 基于HttpUrlConnection的Http客户端封装 --> |
||||
|
<dependency> |
||||
|
<groupId>cn.hutool</groupId> |
||||
|
<artifactId>hutool-http</artifactId> |
||||
|
<version>${hutool.version}</version> |
||||
|
</dependency> |
||||
|
<!-- hutool 加密解密模块,提供对称、非对称和摘要算法封装 --> |
||||
|
<dependency> |
||||
|
<groupId>cn.hutool</groupId> |
||||
|
<artifactId>hutool-crypto</artifactId> |
||||
|
<version>${hutool.version}</version> |
||||
|
</dependency> |
||||
|
<!-- hutool 简单缓存实现 --> |
||||
|
<dependency> |
||||
|
<groupId>cn.hutool</groupId> |
||||
|
<artifactId>hutool-cache</artifactId> |
||||
|
<version>${hutool.version}</version> |
||||
|
</dependency> |
||||
|
<!-- hutool 图片验证码实现 --> |
||||
|
<dependency> |
||||
|
<groupId>cn.hutool</groupId> |
||||
|
<artifactId>hutool-captcha</artifactId> |
||||
|
<version>${hutool.version}</version> |
||||
|
</dependency> |
||||
|
<!-- hutool 针对POI中Excel和Word的封装 --> |
||||
|
<dependency> |
||||
|
<groupId>cn.hutool</groupId> |
||||
|
<artifactId>hutool-poi</artifactId> |
||||
|
<version>${hutool.version}</version> |
||||
|
</dependency> |
||||
|
<!-- hutool JSON实现 --> |
||||
|
<dependency> |
||||
|
<groupId>cn.hutool</groupId> |
||||
|
<artifactId>hutool-json</artifactId> |
||||
|
<version>${hutool.version}</version> |
||||
|
</dependency> |
||||
|
<!-- hutool 定时任务模块,提供类Crontab表达式的定时任务 --> |
||||
|
<dependency> |
||||
|
<groupId>cn.hutool</groupId> |
||||
|
<artifactId>hutool-cron</artifactId> |
||||
|
<version>${hutool.version}</version> |
||||
|
</dependency> |
||||
|
<!-- hutool 系统参数调用封装(JVM信息等) --> |
||||
|
<dependency> |
||||
|
<groupId>cn.hutool</groupId> |
||||
|
<artifactId>hutool-system</artifactId> |
||||
|
<version>${hutool.version}</version> |
||||
|
</dependency> |
||||
|
<!-- hutool 功能更强大的Setting配置文件和Properties封装 --> |
||||
|
<dependency> |
||||
|
<groupId>cn.hutool</groupId> |
||||
|
<artifactId>hutool-setting</artifactId> |
||||
|
<version>${hutool.version}</version> |
||||
|
</dependency> |
||||
|
<!-- hutool 扩展模块,对第三方封装(模板引擎、邮件、Servlet、二维码、Emoji、FTP、分词等) --> |
||||
|
<dependency> |
||||
|
<groupId>cn.hutool</groupId> |
||||
|
<artifactId>hutool-extra</artifactId> |
||||
|
<version>${hutool.version}</version> |
||||
|
</dependency> |
||||
|
<!-- hutool JDK动态代理封装,提供非IOC下的切面支持 --> |
||||
|
<dependency> |
||||
|
<groupId>cn.hutool</groupId> |
||||
|
<artifactId>hutool-aop</artifactId> |
||||
|
<version>${hutool.version}</version> |
||||
|
</dependency> |
||||
|
<!-- hutool 布隆过滤,提供一些Hash算法的布隆过滤 --> |
||||
|
<dependency> |
||||
|
<groupId>cn.hutool</groupId> |
||||
|
<artifactId>hutool-bloomFilter</artifactId> |
||||
|
<version>${hutool.version}</version> |
||||
|
</dependency> |
||||
|
<!-- hutool JDBC封装后的数据操作,基于ActiveRecord思想 --> |
||||
|
<dependency> |
||||
|
<groupId>cn.hutool</groupId> |
||||
|
<artifactId>hutool-db</artifactId> |
||||
|
<version>${hutool.version}</version> |
||||
|
</dependency> |
||||
|
<!-- hutool 自动识别日志实现的日志门面 --> |
||||
|
<dependency> |
||||
|
<groupId>cn.hutool</groupId> |
||||
|
<artifactId>hutool-log</artifactId> |
||||
|
<version>${hutool.version}</version> |
||||
|
</dependency> |
||||
|
<!-- hutool 基于Java的NIO和AIO的Socket封装 --> |
||||
|
<dependency> |
||||
|
<groupId>cn.hutool</groupId> |
||||
|
<artifactId>hutool-socket</artifactId> |
||||
|
<version>${hutool.version}</version> |
||||
|
</dependency> |
||||
|
<!-- hutool 基于DFA模型的多关键字查找 --> |
||||
|
<dependency> |
||||
|
<groupId>cn.hutool</groupId> |
||||
|
<artifactId>hutool-dfa</artifactId> |
||||
|
<version>${hutool.version}</version> |
||||
|
</dependency> |
||||
|
<!-- hutool 脚本执行封装,例如Javascript --> |
||||
|
<dependency> |
||||
|
<groupId>cn.hutool</groupId> |
||||
|
<artifactId>hutool-script</artifactId> |
||||
|
<version>${hutool.version}</version> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>org.hibernate.validator</groupId> |
||||
|
<artifactId>hibernate-validator</artifactId> |
||||
|
<version>${hibernate-validator.version}</version> |
||||
|
<scope>compile</scope> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>org.projectlombok</groupId> |
||||
|
<artifactId>lombok</artifactId> |
||||
|
<optional>true</optional> |
||||
|
<version>${lombok.version}</version> |
||||
|
</dependency> |
||||
|
|
||||
|
<!-- https://mvnrepository.com/artifact/com.deepoove/poi-tl --> |
||||
|
<dependency> |
||||
|
<groupId>com.deepoove</groupId> |
||||
|
<artifactId>poi-tl</artifactId> |
||||
|
<version>${poi-tl.version}</version> |
||||
|
</dependency> |
||||
|
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi --> |
||||
|
<dependency> |
||||
|
<groupId>org.apache.poi</groupId> |
||||
|
<artifactId>poi</artifactId> |
||||
|
<version>${poi.version}</version> |
||||
|
</dependency> |
||||
|
<!--flowable组件--> |
||||
|
<dependency> |
||||
|
<groupId>org.flowable</groupId> |
||||
|
<artifactId>flowable-engine</artifactId> |
||||
|
<version>${flowable.version}</version> |
||||
|
<scope>compile</scope> |
||||
|
</dependency> |
||||
|
|
||||
|
<dependency> |
||||
|
<groupId>org.flowable</groupId> |
||||
|
<artifactId>flowable-spring-boot-starter-basic</artifactId> |
||||
|
<version>${flowable.version}</version> |
||||
|
<exclusions><!-- 需要排除flowable的mybatis依赖,不然会跟mybatis-plus冲突 --> |
||||
|
<exclusion> |
||||
|
<groupId>org.mybatis</groupId> |
||||
|
<artifactId>mybatis</artifactId> |
||||
|
</exclusion> |
||||
|
</exclusions> |
||||
|
</dependency> |
||||
|
|
||||
|
<dependency> |
||||
|
<groupId>org.apache.pdfbox</groupId> |
||||
|
<artifactId>pdfbox</artifactId> |
||||
|
<version>${pdfbox.version}</version> |
||||
|
</dependency> |
||||
|
|
||||
|
</dependencies> |
||||
|
</dependencyManagement> |
||||
|
|
||||
|
<distributionManagement> |
||||
|
<repository> |
||||
|
<id>nexus-releases</id> |
||||
|
<url>http://nexus3.yyundong.com/repository/yxt-mvn-releases/</url> |
||||
|
</repository> |
||||
|
<snapshotRepository> |
||||
|
<id>nexus-snapshots</id> |
||||
|
<url>http://nexus3.yyundong.com/repository/yxt-mvn-snapshot/</url> |
||||
|
</snapshotRepository> |
||||
|
</distributionManagement> |
||||
|
|
||||
|
</project> |
Loading…
Reference in new issue