commit 2b23163569c09ffd4fcc31def8a4abf58f9c849d Author: wangpengfei <1928057482@qq.com> Date: Tue Jul 2 13:58:03 2024 +0800 oms初始化 diff --git a/docs/HELP.md b/docs/HELP.md new file mode 100644 index 0000000..e69de29 diff --git a/gateway/pom.xml b/gateway/pom.xml new file mode 100644 index 0000000..72dc2d8 --- /dev/null +++ b/gateway/pom.xml @@ -0,0 +1,92 @@ + + + + oms-biz + com.yxt + 1.0-SNAPSHOT + + 4.0.0 + + com.yxt.gateway + gateway + + + 8 + 8 + UTF-8 + + + + io.jsonwebtoken + jjwt + 0.9.0 + + + org.springframework.cloud + spring-cloud-starter-gateway + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + org.projectlombok + lombok + 1.18.24 + true + + + org.springframework + spring-webmvc + + + + org.springframework.boot + spring-boot-starter-data-redis + + + io.lettuce + lettuce-core + + + + + redis.clients + jedis + + + com.alibaba + fastjson + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.5.6 + + + + repackage + + + + + + + + src/main/resources + + **/*.yml + + false + + + + \ No newline at end of file diff --git a/gateway/src/main/java/com/yxt/oms/AuthFilter.java b/gateway/src/main/java/com/yxt/oms/AuthFilter.java new file mode 100644 index 0000000..2ad7c2a --- /dev/null +++ b/gateway/src/main/java/com/yxt/oms/AuthFilter.java @@ -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 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 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; + } +} diff --git a/gateway/src/main/java/com/yxt/oms/GatewayApplication.java b/gateway/src/main/java/com/yxt/oms/GatewayApplication.java new file mode 100644 index 0000000..0bfb759 --- /dev/null +++ b/gateway/src/main/java/com/yxt/oms/GatewayApplication.java @@ -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); + }} \ No newline at end of file diff --git a/gateway/src/main/java/com/yxt/oms/RedisUtil.java b/gateway/src/main/java/com/yxt/oms/RedisUtil.java new file mode 100644 index 0000000..766abc4 --- /dev/null +++ b/gateway/src/main/java/com/yxt/oms/RedisUtil.java @@ -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() { + @Override + public Boolean doInRedis(RedisConnection redisConnection) throws DataAccessException { + RedisSerializer 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() { + @Override + public Boolean doInRedis(RedisConnection connection) throws DataAccessException { + RedisSerializer 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 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() { + @Override + public String doInRedis(RedisConnection connection) throws DataAccessException { + RedisSerializer serializer = redisTemplate.getStringSerializer(); + byte[] value = connection.get(serializer.serialize(key)); + return serializer.deserialize(value); + } + }); + return result; + } + + /** + * 正则获取key集合 + * + * @param pattern + * @return + */ + public Set keys(String pattern) { + Set 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 keys = redisTemplate.keys(pattern); + if (keys.size() > 0) { + redisTemplate.delete(keys); + } + + } + + + public Long remove(final String key) { + return (Long) redisTemplate.execute(new RedisCallback() { + @Override + public Long doInRedis(RedisConnection redisConnection) throws DataAccessException { + RedisSerializer 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 hash = redisTemplate.opsForHash(); + hash.put(key, hashKey, value); + } + + /** + * 哈希获取数据 + * + * @param key + * @param hashKey + * @return + */ + public String hmGet(String key, Object hashKey) { + HashOperations hash = redisTemplate.opsForHash(); + return hash.get(key, hashKey); + } + + /** + * 获取哈希 keys + * + * @param key + * @return + */ + public Set hmGetKeys(String key) { + HashOperations hash = redisTemplate.opsForHash(); + return hash.keys(key); + } + + /** + * 删除集合中的key + * + * @param key + * @param hashKey + */ + public void hmDelete(String key, Object hashKey) { + HashOperations hash = redisTemplate.opsForHash(); + hash.delete(key, hashKey); + } + + /** + * 列表添加 + * + * @param k + * @param v + */ + public void lPush(String k, Object v) { + ListOperations list = redisTemplate.opsForList(); + list.rightPush(k, v); + } + + /** + * 列表获取 + * + * @param k + * @param l + * @param l1 + * @return + */ + public List lRange(String k, long l, long l1) { + ListOperations list = redisTemplate.opsForList(); + return list.range(k, l, l1); + } + + /** + * 集合添加 + * + * @param key + * @param value + */ + public void add(String key, Object value) { + SetOperations set = redisTemplate.opsForSet(); + set.add(key, value); + } + + /** + * 集合获取 + * + * @param key + * @return + */ + public Set setMembers(String key) { + SetOperations set = redisTemplate.opsForSet(); + return set.members(key); + } + + /** + * 有序集合添加 + * + * @param key + * @param value + * @param scoure + */ + public void zAdd(String key, Object value, double scoure) { + ZSetOperations zset = redisTemplate.opsForZSet(); + zset.add(key, value, scoure); + } + + /** + * 有序集合获取 + * + * @param key + * @param scoure + * @param scoure1 + * @return + */ + public Set rangeByScore(String key, double scoure, double scoure1) { + ZSetOperations zset = redisTemplate.opsForZSet(); + return zset.rangeByScore(key, scoure, scoure1); + } + + /** + * 实现命令:TTL key 以秒为单位,返回给定key的剩余生存时间 + * @param key + * @return + */ + public long ttl(String key) { + return redisTemplate.getExpire(key); + } +} diff --git a/gateway/src/main/java/com/yxt/oms/utils/CacheConstants.java b/gateway/src/main/java/com/yxt/oms/utils/CacheConstants.java new file mode 100644 index 0000000..899266c --- /dev/null +++ b/gateway/src/main/java/com/yxt/oms/utils/CacheConstants.java @@ -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"; +} diff --git a/gateway/src/main/java/com/yxt/oms/utils/CharsetKit.java b/gateway/src/main/java/com/yxt/oms/utils/CharsetKit.java new file mode 100644 index 0000000..05fa9e0 --- /dev/null +++ b/gateway/src/main/java/com/yxt/oms/utils/CharsetKit.java @@ -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(); + } +} diff --git a/gateway/src/main/java/com/yxt/oms/utils/Constants.java b/gateway/src/main/java/com/yxt/oms/utils/Constants.java new file mode 100644 index 0000000..c73b6bd --- /dev/null +++ b/gateway/src/main/java/com/yxt/oms/utils/Constants.java @@ -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; +} diff --git a/gateway/src/main/java/com/yxt/oms/utils/Convert.java b/gateway/src/main/java/com/yxt/oms/utils/Convert.java new file mode 100644 index 0000000..73dff60 --- /dev/null +++ b/gateway/src/main/java/com/yxt/oms/utils/Convert.java @@ -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 { + + /** + * 转换为字符串
+ * 如果给定的值为null,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @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(); + } + + /** + * 转换为字符串
+ * 如果给定的值为null,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static String toStr(Object value) + { + return toStr(value, null); + } + + /** + * 转换为字符
+ * 如果给定的值为null,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @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); + } + + /** + * 转换为字符
+ * 如果给定的值为null,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Character toChar(Object value) + { + return toChar(value, null); + } + + /** + * 转换为byte
+ * 如果给定的值为null,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @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
+ * 如果给定的值为null,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Byte toByte(Object value) + { + return toByte(value, null); + } + + /** + * 转换为Short
+ * 如果给定的值为null,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @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
+ * 如果给定的值为null,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Short toShort(Object value) + { + return toShort(value, null); + } + + /** + * 转换为Number
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @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
+ * 如果给定的值为空,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Number toNumber(Object value) + { + return toNumber(value, null); + } + + /** + * 转换为int
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @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
+ * 如果给定的值为null,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Integer toInt(Object value) + { + return toInt(value, null); + } + + /** + * 转换为Integer数组
+ * + * @param str 被转换的值 + * @return 结果 + */ + public static Integer[] toIntArray(String str) + { + return toIntArray(",", str); + } + + /** + * 转换为Long数组
+ * + * @param str 被转换的值 + * @return 结果 + */ + public static Long[] toLongArray(String str) + { + return toLongArray(",", str); + } + + /** + * 转换为Integer数组
+ * + * @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数组
+ * + * @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数组
+ * + * @param str 被转换的值 + * @return 结果 + */ + public static String[] toStrArray(String str) + { + return toStrArray(",", str); + } + + /** + * 转换为String数组
+ * + * @param split 分隔符 + * @param split 被转换的值 + * @return 结果 + */ + public static String[] toStrArray(String split, String str) + { + return str.split(split); + } + + /** + * 转换为long
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @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
+ * 如果给定的值为null,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Long toLong(Object value) + { + return toLong(value, null); + } + + /** + * 转换为double
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @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
+ * 如果给定的值为空,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Double toDouble(Object value) + { + return toDouble(value, null); + } + + /** + * 转换为Float
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @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
+ * 如果给定的值为空,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Float toFloat(Object value) + { + return toFloat(value, null); + } + + /** + * 转换为boolean
+ * String支持的值为:true、false、yes、ok、no,1,0 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @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
+ * 如果给定的值为空,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Boolean toBool(Object value) + { + return toBool(value, null); + } + + /** + * 转换为Enum对象
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * + * @param clazz Enum的Class + * @param value 值 + * @param defaultValue 默认值 + * @return Enum + */ + public static > E toEnum(Class 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对象
+ * 如果给定的值为空,或者转换失败,返回默认值null
+ * + * @param clazz Enum的Class + * @param value 值 + * @return Enum + */ + public static > E toEnum(Class clazz, Object value) + { + return toEnum(clazz, value, null); + } + + /** + * 转换为BigInteger
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @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
+ * 如果给定的值为空,或者转换失败,返回默认值null
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static BigInteger toBigInteger(Object value) + { + return toBigInteger(value, null); + } + + /** + * 转换为BigDecimal
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @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
+ * 如果给定的值为空,或者转换失败,返回默认值
+ * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static BigDecimal toBigDecimal(Object value) + { + return toBigDecimal(value, null); + } + + /** + * 将对象转为字符串
+ * 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 + * + * @param obj 对象 + * @return 字符串 + */ + public static String utf8Str(Object obj) + { + return str(obj, CharsetKit.CHARSET_UTF_8); + } + + /** + * 将对象转为字符串
+ * 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)); + } + + /** + * 将对象转为字符串
+ * 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 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 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("^整$", "零元整"); + } +} diff --git a/gateway/src/main/java/com/yxt/oms/utils/HttpStatus.java b/gateway/src/main/java/com/yxt/oms/utils/HttpStatus.java new file mode 100644 index 0000000..8f55cc8 --- /dev/null +++ b/gateway/src/main/java/com/yxt/oms/utils/HttpStatus.java @@ -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"; + +} diff --git a/gateway/src/main/java/com/yxt/oms/utils/HttpUtils.java b/gateway/src/main/java/com/yxt/oms/utils/HttpUtils.java new file mode 100644 index 0000000..58bf7b0 --- /dev/null +++ b/gateway/src/main/java/com/yxt/oms/utils/HttpUtils.java @@ -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 map) { + // 设置参数 + List formparams = new ArrayList(); + for (Map.Entry 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; + } + +} diff --git a/gateway/src/main/java/com/yxt/oms/utils/IResultCodeMsg.java b/gateway/src/main/java/com/yxt/oms/utils/IResultCodeMsg.java new file mode 100644 index 0000000..bceb953 --- /dev/null +++ b/gateway/src/main/java/com/yxt/oms/utils/IResultCodeMsg.java @@ -0,0 +1,44 @@ +/********************************************************* + ********************************************************* + ******************** ******************* + ************* ************ + ******* _oo0oo_ ******* + *** o8888888o *** + * 88" . "88 * + * (| -_- |) * + * 0\ = /0 * + * ___/`---'\___ * + * .' \\| |// '. * + * / \\||| : |||// \ * + * / _||||| -:- |||||- \ * + * | | \\\ - /// | | * + * | \_| ''\---/'' |_/ | * + * \ .-\__ '-' ___/-. / * + * ___'. .' /--.--\ `. .'___ * + * ."" '< `.___\_<|>_/___.' >' "". * + * | | : `- \`.;`\ _ /`;.`/ - ` : | | * + * \ \ `_. \_ __\ /__ _/ .-` / / * + * =====`-.____`.___ \_____/___.-`___.-'===== * + * `=---=' * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * + *********__佛祖保佑__永无BUG__验收通过__钞票多多__********* + *********************************************************/ +package com.yxt.oms.utils; + +/** + * Project: yxt-common
+ * File: IResultCodeMsg.java
+ * Class: com.yxt.common.core.result.IResultCodeMsg
+ * Description: <描述类的功能>.
+ * Copyright: Copyright (c) 2011
+ * Company: https://gitee.com/liuzp315
+ * Makedate: 2021/9/11 下午11:00
+ * + * @author popo + * @version 1.0 + * @since 1.0 + */ +public interface IResultCodeMsg { + String getCode(); + String getMsg(); +} diff --git a/gateway/src/main/java/com/yxt/oms/utils/IgnoreWhiteProperties.java b/gateway/src/main/java/com/yxt/oms/utils/IgnoreWhiteProperties.java new file mode 100644 index 0000000..33cdc9a --- /dev/null +++ b/gateway/src/main/java/com/yxt/oms/utils/IgnoreWhiteProperties.java @@ -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 whites = new ArrayList<>(); + + public List getWhites() { + return whites; + } + + public void setWhites(List whites) { + this.whites = whites; + } + + private List whitesTwo = new ArrayList<>(); + + public List getWhitesTwo() { + return whitesTwo; + } + + public void setWhitesTwo(List whitesTwo) { + this.whitesTwo = whitesTwo; + } +} diff --git a/gateway/src/main/java/com/yxt/oms/utils/ResultBean.java b/gateway/src/main/java/com/yxt/oms/utils/ResultBean.java new file mode 100644 index 0000000..9fde15f --- /dev/null +++ b/gateway/src/main/java/com/yxt/oms/utils/ResultBean.java @@ -0,0 +1,191 @@ +package com.yxt.oms.utils; + +import java.io.Serializable; + +/** + * Project: yxt-common-core
+ * File: ResultBean.java
+ * Class: com.yxt.common.core.result.ResultBean
+ * Description: 通过接口、Rest、逻辑处理执行后的结果信息.
+ * Copyright: Copyright (c) 2011
+ * Company: https://gitee.com/liuzp315
+ * Makedate: 2020/8/4 0:51
+ * + * @author liupopo + * @version 1.0 + * @since 1.0 + */ +public class ResultBean 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 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 setSuccess(boolean success) { + this.success = success; + return this; + } + + public String getMsg() { + return msg; + } + + public ResultBean setMsg(String msg) { + this.msg = msg; + return this; + } + + public String getCode() { + return code; + } + + public ResultBean setCode(String code) { + this.code = code; + return this; + } + + public T getData() { + return data; + } + + public ResultBean setData(T data) { + this.data = data; + return this; + } + + public ResultBean successOne() { + this.setSuccess(true); + this.setCode("0"); + this.setMessage("成功!"); + return this; + } + + public ResultBean failOne() { + this.setSuccess(false); + this.setCode(String.valueOf(HttpStatus.ERROR)); + this.setMessage("操作失败!"); + return this; + } + + public ResultBean success() { + this.setSuccess(true); + this.setCode(String.valueOf(HttpStatus.SUCCESS)); + this.setMsg("操作成功!"); + return this; + } + + public ResultBean fail() { + this.setSuccess(false); + this.setCode(String.valueOf(HttpStatus.ERROR)); + this.setMsg("操作失败!"); + return this; + } + + public static ResultBean fireSuccess() { + ResultBean rb = new ResultBean(); + rb.setSuccess(true); + rb.setCode(String.valueOf(HttpStatus.SUCCESS)); + rb.setMsg("操作成功!"); + return rb; + } + + public static ResultBean fireFail() { + ResultBean rb = new ResultBean(); + rb.setSuccess(false); + rb.setCode(String.valueOf(HttpStatus.ERROR)); + rb.setMsg("操作失败!"); + return rb; + } + + /** + * 设置返回code及msg + * + * @param codeMsg Code和Msg的枚举 + * @return + */ + public ResultBean setCode(IResultCodeMsg codeMsg) { + this.code = codeMsg.getCode(); + this.msg = codeMsg.getMsg(); + return this; + } + + /** + * 返回失败信息,并指定结果code + * + * @param codeMsg Code和Msg的枚举 + * @return + */ + public ResultBean fail(IResultCodeMsg codeMsg) { + this.setSuccess(false); + this.code = codeMsg.getCode(); + this.msg = codeMsg.getMsg(); + return this; + } + +} diff --git a/gateway/src/main/java/com/yxt/oms/utils/StrFormatter.java b/gateway/src/main/java/com/yxt/oms/utils/StrFormatter.java new file mode 100644 index 0000000..59889a3 --- /dev/null +++ b/gateway/src/main/java/com/yxt/oms/utils/StrFormatter.java @@ -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 = '}'; + + /** + * 格式化字符串
+ * 此方法只是简单将占位符 {} 按照顺序替换为参数
+ * 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可
+ * 例:
+ * 通常使用:format("this is {} for {}", "a", "b") -> this is a for b
+ * 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a
+ * 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b
+ * + * @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(); + } +} diff --git a/gateway/src/main/java/com/yxt/oms/utils/StringUtils.java b/gateway/src/main/java/com/yxt/oms/utils/StringUtils.java new file mode 100644 index 0000000..3eafa45 --- /dev/null +++ b/gateway/src/main/java/com/yxt/oms/utils/StringUtils.java @@ -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 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); + } + + /** + * 格式化文本, {} 表示占位符
+ * 此方法只是简单将占位符 {} 按照顺序替换为参数
+ * 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可
+ * 例:
+ * 通常使用:format("this is {} for {}", "a", "b") -> this is a for b
+ * 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a
+ * 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b
+ * + * @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 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 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 cast(Object obj) { + return (T) obj; + } +} diff --git a/gateway/src/main/resources/application-dev.yml b/gateway/src/main/resources/application-dev.yml new file mode 100644 index 0000000..8faaa6b --- /dev/null +++ b/gateway/src/main/resources/application-dev.yml @@ -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 # 连接超时时间(毫秒) \ No newline at end of file diff --git a/gateway/src/main/resources/application-pro.yml b/gateway/src/main/resources/application-pro.yml new file mode 100644 index 0000000..ab4c3e7 --- /dev/null +++ b/gateway/src/main/resources/application-pro.yml @@ -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 # 连接超时时间(毫秒) \ No newline at end of file diff --git a/gateway/src/main/resources/application-test.yml b/gateway/src/main/resources/application-test.yml new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/gateway/src/main/resources/application-test.yml @@ -0,0 +1 @@ + diff --git a/gateway/src/main/resources/application.yml b/gateway/src/main/resources/application.yml new file mode 100644 index 0000000..2e647a1 --- /dev/null +++ b/gateway/src/main/resources/application.yml @@ -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/** diff --git a/oms/README.md b/oms/README.md new file mode 100644 index 0000000..5d571fd --- /dev/null +++ b/oms/README.md @@ -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 +``` \ No newline at end of file diff --git a/oms/pom.xml b/oms/pom.xml new file mode 100644 index 0000000..f31e194 --- /dev/null +++ b/oms/pom.xml @@ -0,0 +1,168 @@ + + + + oms-biz + com.yxt + 1.0-SNAPSHOT + + 4.0.0 + + com.yxt.oms + oms + + + 8 + 8 + UTF-8 + + + + com.alibaba + easyexcel + 3.3.2 + + + com.yxt + yxt-common-base + 0.0.1 + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + + mysql + mysql-connector-java + runtime + + + com.baomidou + mybatis-plus-boot-starter + + + com.baomidou + mybatis-plus-annotation + + + org.projectlombok + lombok + 1.18.24 + true + + + + com.yxt + yxt-common-base + 0.0.1 + + + + org.springframework.boot + spring-boot-starter-web + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + + + mysql + mysql-connector-java + runtime + + + + com.baomidou + mybatis-plus-boot-starter + + + com.baomidou + mybatis-plus-annotation + + + junit + junit + compile + + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + + cn.dev33 + sa-token-spring-boot-starter + 1.37.0 + + + cn.hutool + hutool-all + 5.8.23 + + + cn.hutool + hutool-core + 5.8.23 + + + com.google.zxing + core + 3.5.2 + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.5.6 + + + + repackage + + + + + + + + src/main/java + + **/*Mapper.xml + + + + src/main/resources + + **/*.* + + false + + + + \ No newline at end of file diff --git a/oms/src/main/java/com/yxt/oms/OmsApplication.java b/oms/src/main/java/com/yxt/oms/OmsApplication.java new file mode 100644 index 0000000..b13bef2 --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/OmsApplication.java @@ -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); + } +} \ No newline at end of file diff --git a/oms/src/main/java/com/yxt/oms/apiadmin/AdminHomeRest.java b/oms/src/main/java/com/yxt/oms/apiadmin/AdminHomeRest.java new file mode 100644 index 0000000..228831b --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/apiadmin/AdminHomeRest.java @@ -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 { + +} diff --git a/oms/src/main/java/com/yxt/oms/apiadmin/aggregation/PurchaseReceiptBillRest.java b/oms/src/main/java/com/yxt/oms/apiadmin/aggregation/PurchaseReceiptBillRest.java new file mode 100644 index 0000000..4607fc9 --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/apiadmin/aggregation/PurchaseReceiptBillRest.java @@ -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> listPage(@RequestBody PagerQuery pq) { + return baseBrandInfoService.listPage(pq); + } + + @ApiOperation("查询所有的品牌") + @PostMapping("/listAll") + public ResultBean> listAll(@RequestBody OrgPathQuery query) { + return baseBrandInfoService.listAll(query); + } + + @ApiOperation("保存") + @PostMapping("/save") + public ResultBean save(@RequestBody PurchaseReceiptBillDto dto) { + return baseBrandInfoService.save(dto); + } + + @ApiOperation("初始化") + @GetMapping("/initialization/{sid}") + public ResultBean 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); + } +} diff --git a/oms/src/main/java/com/yxt/oms/apiwx/WxHomeRest.java b/oms/src/main/java/com/yxt/oms/apiwx/WxHomeRest.java new file mode 100644 index 0000000..97fdbf3 --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/apiwx/WxHomeRest.java @@ -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 { + +} diff --git a/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbill/PurchaseReceiptBill.java b/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbill/PurchaseReceiptBill.java new file mode 100644 index 0000000..27eb4cc --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbill/PurchaseReceiptBill.java @@ -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 + + +} diff --git a/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbill/PurchaseReceiptBillDto.java b/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbill/PurchaseReceiptBillDto.java new file mode 100644 index 0000000..2f3c456 --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbill/PurchaseReceiptBillDto.java @@ -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 purchaseReceiptBillList=new ArrayList<>(); +} diff --git a/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbill/PurchaseReceiptBillMapper.java b/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbill/PurchaseReceiptBillMapper.java new file mode 100644 index 0000000..c826795 --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbill/PurchaseReceiptBillMapper.java @@ -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 { + + IPage listPage(IPage page, @Param(Constants.WRAPPER) QueryWrapper qw); +} diff --git a/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbill/PurchaseReceiptBillMapper.xml b/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbill/PurchaseReceiptBillMapper.xml new file mode 100644 index 0000000..c8951f3 --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbill/PurchaseReceiptBillMapper.xml @@ -0,0 +1,15 @@ + + + + + + + + \ No newline at end of file diff --git a/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbill/PurchaseReceiptBillQuery.java b/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbill/PurchaseReceiptBillQuery.java new file mode 100644 index 0000000..5ef243c --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbill/PurchaseReceiptBillQuery.java @@ -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; +} diff --git a/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbill/PurchaseReceiptBillService.java b/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbill/PurchaseReceiptBillService.java new file mode 100644 index 0000000..238d0cf --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbill/PurchaseReceiptBillService.java @@ -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 { + @Autowired + private FileUploadComponent fileUploadComponent; + @Autowired + PurchaseReceiptBillFeign purchaseReceiptBillFeign; + @Autowired + WarehouseAnsBillFeign warehouseAnsBillFeignl; + + public ResultBean> listPage(PagerQuery pq) { + ResultBean rb = ResultBean.fireFail(); + return purchaseReceiptBillFeign.listPage(pq); + } + public ResultBean> listAll(OrgPathQuery query) { + ResultBean rb = ResultBean.fireFail(); + + return purchaseReceiptBillFeign.listAll(query); +} + public ResultBean 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 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 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); + } + +} diff --git a/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbill/PurchaseReceiptBillVo.java b/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbill/PurchaseReceiptBillVo.java new file mode 100644 index 0000000..677f583 --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbill/PurchaseReceiptBillVo.java @@ -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 +} diff --git a/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbilldetail/PurchaseReceiptBillDetail.java b/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbilldetail/PurchaseReceiptBillDetail.java new file mode 100644 index 0000000..513db99 --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbilldetail/PurchaseReceiptBillDetail.java @@ -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 + +} diff --git a/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbilldetail/PurchaseReceiptBillDetailDto.java b/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbilldetail/PurchaseReceiptBillDetailDto.java new file mode 100644 index 0000000..334cb1d --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbilldetail/PurchaseReceiptBillDetailDto.java @@ -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 +} diff --git a/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbilldetail/PurchaseReceiptBillDetailQuery.java b/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbilldetail/PurchaseReceiptBillDetailQuery.java new file mode 100644 index 0000000..6c846c4 --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbilldetail/PurchaseReceiptBillDetailQuery.java @@ -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; +} diff --git a/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbilldetail/PurchaseReceiptBillDetailVo.java b/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbilldetail/PurchaseReceiptBillDetailVo.java new file mode 100644 index 0000000..3f730b8 --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/biz/func/purchasereceiptbilldetail/PurchaseReceiptBillDetailVo.java @@ -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 +} diff --git a/oms/src/main/java/com/yxt/oms/biz/func/warehouseansbill/WarehouseAnsBill.java b/oms/src/main/java/com/yxt/oms/biz/func/warehouseansbill/WarehouseAnsBill.java new file mode 100644 index 0000000..86556d3 --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/biz/func/warehouseansbill/WarehouseAnsBill.java @@ -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; +} diff --git a/oms/src/main/java/com/yxt/oms/biz/func/warehouseansbill/WarehouseAnsBillDto.java b/oms/src/main/java/com/yxt/oms/biz/func/warehouseansbill/WarehouseAnsBillDto.java new file mode 100644 index 0000000..991dcac --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/biz/func/warehouseansbill/WarehouseAnsBillDto.java @@ -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 wmsAnsBillDetailList = new ArrayList<>(); +} diff --git a/oms/src/main/java/com/yxt/oms/biz/func/warehouseansbill/WarehouseAnsBillQuery.java b/oms/src/main/java/com/yxt/oms/biz/func/warehouseansbill/WarehouseAnsBillQuery.java new file mode 100644 index 0000000..9b8aae9 --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/biz/func/warehouseansbill/WarehouseAnsBillQuery.java @@ -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; +} diff --git a/oms/src/main/java/com/yxt/oms/biz/func/warehouseansbill/WarehouseAnsBillVo.java b/oms/src/main/java/com/yxt/oms/biz/func/warehouseansbill/WarehouseAnsBillVo.java new file mode 100644 index 0000000..66a8ce3 --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/biz/func/warehouseansbill/WarehouseAnsBillVo.java @@ -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;*/ + + +} diff --git a/oms/src/main/java/com/yxt/oms/biz/func/warehouseansbill/WarehouseAnsDetailsVo.java b/oms/src/main/java/com/yxt/oms/biz/func/warehouseansbill/WarehouseAnsDetailsVo.java new file mode 100644 index 0000000..f938f9c --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/biz/func/warehouseansbill/WarehouseAnsDetailsVo.java @@ -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 list = new ArrayList<>(); +} diff --git a/oms/src/main/java/com/yxt/oms/biz/func/warehouseansbilldetail/WarehouseAnsBillDetailDto.java b/oms/src/main/java/com/yxt/oms/biz/func/warehouseansbilldetail/WarehouseAnsBillDetailDto.java new file mode 100644 index 0000000..7f6f68b --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/biz/func/warehouseansbilldetail/WarehouseAnsBillDetailDto.java @@ -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; +} diff --git a/oms/src/main/java/com/yxt/oms/biz/func/warehouseansbilldetail/WarehouseAnsListDetailsVo.java b/oms/src/main/java/com/yxt/oms/biz/func/warehouseansbilldetail/WarehouseAnsListDetailsVo.java new file mode 100644 index 0000000..d9f382b --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/biz/func/warehouseansbilldetail/WarehouseAnsListDetailsVo.java @@ -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;*/ + + +} diff --git a/oms/src/main/java/com/yxt/oms/biz/package-info.java b/oms/src/main/java/com/yxt/oms/biz/package-info.java new file mode 100644 index 0000000..90eba6d --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/biz/package-info.java @@ -0,0 +1,4 @@ +/** + * 宇信通 仓库管理 项目后台逻辑和接口 + */ +package com.yxt.oms.biz; \ No newline at end of file diff --git a/oms/src/main/java/com/yxt/oms/config/SaTokenConfigure.java b/oms/src/main/java/com/yxt/oms/config/SaTokenConfigure.java new file mode 100644 index 0000000..3e973cb --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/config/SaTokenConfigure.java @@ -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/**") +// ; +// } +//} diff --git a/oms/src/main/java/com/yxt/oms/config/SaTokenGloableException.java b/oms/src/main/java/com/yxt/oms/config/SaTokenGloableException.java new file mode 100644 index 0000000..95d890c --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/config/SaTokenGloableException.java @@ -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); + } +} diff --git a/oms/src/main/java/com/yxt/oms/config/package-info.java b/oms/src/main/java/com/yxt/oms/config/package-info.java new file mode 100644 index 0000000..de8c590 --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/config/package-info.java @@ -0,0 +1,4 @@ +/** + * 宇信通监管项目-光伏(山海新能源)项目后台逻辑和接口-接口声明 + */ +package com.yxt.oms.config; \ No newline at end of file diff --git a/oms/src/main/java/com/yxt/oms/feign/package-info.java b/oms/src/main/java/com/yxt/oms/feign/package-info.java new file mode 100644 index 0000000..1f51f37 --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/feign/package-info.java @@ -0,0 +1,4 @@ +/** + * 宇信通监管项目-光伏(山海新能源)项目后台逻辑和接口-接口声明 + */ +package com.yxt.oms.feign; \ No newline at end of file diff --git a/oms/src/main/java/com/yxt/oms/feign/purchase/purchasereceiptbill/PurchaseReceiptBillFeign.java b/oms/src/main/java/com/yxt/oms/feign/purchase/purchasereceiptbill/PurchaseReceiptBillFeign.java new file mode 100644 index 0000000..98a46c1 --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/feign/purchase/purchasereceiptbill/PurchaseReceiptBillFeign.java @@ -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> listPage(@RequestBody PagerQuery pq); + + @ApiOperation("保存修改") + @PostMapping("/saveOrUpdate") + public ResultBean saveOrUpdate(@RequestBody PurchaseReceiptBillDto dto); + @ApiOperation("查询所有的品牌") + @PostMapping("/listAll") + public ResultBean> listAll(@RequestBody OrgPathQuery query); + @ApiOperation("初始化") + @GetMapping("/initialization/{sid}") + public ResultBean 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 getBrandByName(@PathVariable("name") String name); + @ApiOperation("根据sid批量删除") + @DeleteMapping("/delBySids") + public ResultBean delBySids(@RequestBody String[] sids); + +} diff --git a/oms/src/main/java/com/yxt/oms/feign/purchase/purchasereceiptbill/PurchaseReceiptBillFeignFallback.java b/oms/src/main/java/com/yxt/oms/feign/purchase/purchasereceiptbill/PurchaseReceiptBillFeignFallback.java new file mode 100644 index 0000000..cf8fb79 --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/feign/purchase/purchasereceiptbill/PurchaseReceiptBillFeignFallback.java @@ -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> listPage(PagerQuery pq) { + return null; + } + + @Override + public ResultBean saveOrUpdate(PurchaseReceiptBillDto dto) { + return null; + } + + @Override + public ResultBean> listAll(OrgPathQuery query) { + return null; + } + + + @Override + public ResultBean initialization(String sid) { + return null; + } + + @Override + public ResultBean updateIsEnable(String sid, String isEnable) { + return null; + } + + @Override + public ResultBean getBrandByName(String name) { + return null; + } + + @Override + public ResultBean delBySids(String[] sids) { + return null; + } +} diff --git a/oms/src/main/java/com/yxt/oms/feign/warehouse/warehouseansbill/WarehouseAnsBillFeign.java b/oms/src/main/java/com/yxt/oms/feign/warehouse/warehouseansbill/WarehouseAnsBillFeign.java new file mode 100644 index 0000000..73b1965 --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/feign/warehouse/warehouseansbill/WarehouseAnsBillFeign.java @@ -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(门户建设)
+ * File: SysRoleFeign.java
+ * Class: com.yxt.anrui.portal.api.sysrole.SysRoleFeign
+ * Description: 角色.
+ * Copyright: Copyright (c) 2011
+ * Company: https://gitee.com/liuzp315
+ * Makedate: 2021-08-03 00:24:29
+ * + * @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 saveOrUpdate(@RequestBody WarehouseAnsBillDto dto); + @PostMapping("saveBill") + @ApiOperation("oms推送预期到货通知单") + ResultBean saveBill(@RequestBody WarehouseAnsBillDto dto); + + /* @PostMapping("pageList") + @ApiOperation("收货单据选择") + ResultBean> pageList(@RequestBody PagerQuery pagerQuery) { + ResultBean> rb = ResultBean.fireFail(); + PagerVo pv = wmsAnsBillService.listPage(pagerQuery); + return rb.success().setData(pv); + }*/ + + @PostMapping("listPage") + @ApiOperation("分页列表") + ResultBean> listPage(@RequestBody PagerQuery pagerQuery); + + @GetMapping("details") + @ApiOperation("详情") + ResultBean details(@RequestParam("sid") String sid); +} \ No newline at end of file diff --git a/oms/src/main/java/com/yxt/oms/feign/warehouse/warehouseansbill/WarehouseAnsBillFeignFallback.java b/oms/src/main/java/com/yxt/oms/feign/warehouse/warehouseansbill/WarehouseAnsBillFeignFallback.java new file mode 100644 index 0000000..9182ddf --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/feign/warehouse/warehouseansbill/WarehouseAnsBillFeignFallback.java @@ -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(门户建设)
+ * File: SysRoleFeignFallback.java
+ * Class: com.yxt.anrui.portal.api.sysrole.SysRoleFeignFallback
+ * Description: 角色.
+ * Copyright: Copyright (c) 2011
+ * Company: https://gitee.com/liuzp315
+ * Makedate: 2021-08-03 00:24:29
+ * + * @author liupopo + * @version 1.0 + * @since 1.0 + */ +@Component +public class WarehouseAnsBillFeignFallback implements WarehouseAnsBillFeign { + + + @Override + public ResultBean saveOrUpdate(WarehouseAnsBillDto dto) { + return null; + } + + @Override + public ResultBean saveBill(WarehouseAnsBillDto dto) { + return null; + } + + @Override + public ResultBean> listPage(PagerQuery pagerQuery) { + return null; + } + + @Override + public ResultBean details(String sid) { + return null; + } +} \ No newline at end of file diff --git a/oms/src/main/java/com/yxt/oms/utils/DoubleUtils.java b/oms/src/main/java/com/yxt/oms/utils/DoubleUtils.java new file mode 100644 index 0000000..e8b1c5c --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/utils/DoubleUtils.java @@ -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; + } +} diff --git a/oms/src/main/java/com/yxt/oms/utils/ExcelUtil.java b/oms/src/main/java/com/yxt/oms/utils/ExcelUtil.java new file mode 100644 index 0000000..b6bc872 --- /dev/null +++ b/oms/src/main/java/com/yxt/oms/utils/ExcelUtil.java @@ -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 readExcel(MultipartFile file) throws IOException { + //检查文件 + checkFile(file); + //获得Workbook工作薄对象 + Workbook workbook = getWorkBook(file); + //创建返回对象,把每行中的值作为一个数组,所有行作为一个集合返回 + List list = new ArrayList(); + 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 + + + + + + + + + %yellow(%date{yyyy-MM-dd HH:mm:ss}) |%highlight(%-5level) |%green(%logger:%line) |%blue(%msg%n) + + + + + + + + + + + + + + ${log.base}.log + + ${log.base}.%d{yyyyMMdd}.%i.log.zip + + + + 1MB + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} + -%msg%n + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..0b9d004 --- /dev/null +++ b/pom.xml @@ -0,0 +1,404 @@ + + + 4.0.0 + + com.yxt + oms-biz + pom + 1.0-SNAPSHOT + + gateway + oms + + + + + + 1.8 + + UTF-8 + + UTF-8 + 1.8 + 1.8 + + + + 2.2.9.RELEASE + + Hoxton.SR6 + + 2.2.1.RELEASE + + 1.3.0 + + + + 2.5 + 1.14 + + 1.9.3 + + 2.6.2 + + + 3.4.0 + + 1.2.73 + + 0.9.1 + + + + 2.9.2 + 2.0.5 + + 3.17 + + 2.3.2 + + 1.19 + + 1.7 + + 5.4.0 + 6.0.20.Final + 1.18.24 + 3.1.0 + 3.10.1 + 2.2.9.RELEASE + 1.8.1 + 4.1.2 + 6.5.0 + 2.0.25 + + + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + com.alibaba.cloud + spring-cloud-alibaba-dependencies + ${spring-cloud-alibaba.version} + pom + import + + + + com.alibaba.nacos + nacos-client + ${nacos.version} + + + + org.springframework.boot + spring-boot-starter-data-redis + ${redis.version} + + + io.lettuce + lettuce-core + + + + + + com.auth0 + java-jwt + ${java-jwt.version} + + + + redis.clients + jedis + ${jedis.version} + + + + commons-io + commons-io + ${commons.io.version} + + + commons-codec + commons-codec + ${commons-codec.version} + + + + commons-beanutils + commons-beanutils + ${commons.beanutils.version} + + + + org.apache.commons + commons-pool2 + ${common-pool.version} + + + com.baomidou + mybatis-plus-boot-starter + ${mybatis-plus.version} + + + com.baomidou + mybatis-plus-annotation + ${mybatis-plus.version} + + + + com.alibaba + fastjson + ${fastjson.version} + + + + io.jsonwebtoken + jjwt + ${jjwt.version} + + + + + io.springfox + springfox-swagger2 + ${swagger.fox.version} + + + io.springfox + springfox-swagger-ui + ${swagger.fox.version} + + + com.github.xiaoymin + knife4j-dependencies + ${knife4j-Swagger} + pom + import + + + + org.apache.poi + poi-ooxml + ${poi.version} + + + + com.github.penggle + kaptcha + ${kaptcha.version} + + + + eu.bitwalker + UserAgentUtils + ${bitwalker.version} + + + + org.apache.velocity + velocity + ${velocity.version} + + + + + cn.hutool + hutool-all + ${hutool.version} + + + + cn.hutool + hutool-core + ${hutool.version} + + + + cn.hutool + hutool-http + ${hutool.version} + + + + cn.hutool + hutool-crypto + ${hutool.version} + + + + cn.hutool + hutool-cache + ${hutool.version} + + + + cn.hutool + hutool-captcha + ${hutool.version} + + + + cn.hutool + hutool-poi + ${hutool.version} + + + + cn.hutool + hutool-json + ${hutool.version} + + + + cn.hutool + hutool-cron + ${hutool.version} + + + + cn.hutool + hutool-system + ${hutool.version} + + + + cn.hutool + hutool-setting + ${hutool.version} + + + + cn.hutool + hutool-extra + ${hutool.version} + + + + cn.hutool + hutool-aop + ${hutool.version} + + + + cn.hutool + hutool-bloomFilter + ${hutool.version} + + + + cn.hutool + hutool-db + ${hutool.version} + + + + cn.hutool + hutool-log + ${hutool.version} + + + + cn.hutool + hutool-socket + ${hutool.version} + + + + cn.hutool + hutool-dfa + ${hutool.version} + + + + cn.hutool + hutool-script + ${hutool.version} + + + org.hibernate.validator + hibernate-validator + ${hibernate-validator.version} + compile + + + org.projectlombok + lombok + true + ${lombok.version} + + + + + com.deepoove + poi-tl + ${poi-tl.version} + + + + org.apache.poi + poi + ${poi.version} + + + + org.flowable + flowable-engine + ${flowable.version} + compile + + + + org.flowable + flowable-spring-boot-starter-basic + ${flowable.version} + + + org.mybatis + mybatis + + + + + + org.apache.pdfbox + pdfbox + ${pdfbox.version} + + + + + + + + nexus-releases + http://nexus3.yyundong.com/repository/yxt-mvn-releases/ + + + nexus-snapshots + http://nexus3.yyundong.com/repository/yxt-mvn-snapshot/ + + + + \ No newline at end of file