diff --git a/dsAi/target/classes/com/dsideal/Res/Util/AiPpt/Doc/文档.txt b/dsAi/target/classes/com/dsideal/Res/Util/AiPpt/Doc/文档.txt deleted file mode 100644 index cfd6e929..00000000 --- a/dsAi/target/classes/com/dsideal/Res/Util/AiPpt/Doc/文档.txt +++ /dev/null @@ -1,16 +0,0 @@ -# 官网 -https://docmee.cn/ - -# 用户名与密码 -18686619970 -密码:手机验证码 - -# 体验 -https://www.veasion.cn/AiPPT/ - -# 充值 -https://open.docmee.cn/open/workspace/top-up -未充值 - -# 模板选择【展示】 -https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/202505131336410.png \ No newline at end of file diff --git a/dsAi/target/classes/com/dsideal/Res/Util/DashScope/Doc/文档.txt b/dsAi/target/classes/com/dsideal/Res/Util/DashScope/Doc/文档.txt deleted file mode 100644 index 54df7a91..00000000 --- a/dsAi/target/classes/com/dsideal/Res/Util/DashScope/Doc/文档.txt +++ /dev/null @@ -1 +0,0 @@ -https://help.aliyun.com/zh/model-studio/emo-api?spm=a2c4g.11186623.help-menu-2400256.d_2_3_4_1.7d8a5f84mfOU9j \ No newline at end of file diff --git a/dsAi/target/classes/com/dsideal/Res/Util/HuoShanFangZhou/Doc/文档.txt b/dsAi/target/classes/com/dsideal/Res/Util/HuoShanFangZhou/Doc/文档.txt deleted file mode 100644 index 49439e6c..00000000 --- a/dsAi/target/classes/com/dsideal/Res/Util/HuoShanFangZhou/Doc/文档.txt +++ /dev/null @@ -1 +0,0 @@ -https://www.volcengine.com/docs/82379/1520757 \ No newline at end of file diff --git a/dsAi/target/classes/com/dsideal/Res/Util/KeLing/Doc/文档.txt b/dsAi/target/classes/com/dsideal/Res/Util/KeLing/Doc/文档.txt deleted file mode 100644 index c5637d46..00000000 --- a/dsAi/target/classes/com/dsideal/Res/Util/KeLing/Doc/文档.txt +++ /dev/null @@ -1,9 +0,0 @@ -# 可灵AI使用指南-图片生成 -https://docs.qingque.cn/d/home/eZQApd0EZqQHWXBEi7lL16_lD?identityId=26L1FFNIZ7r#section=h.60mmflz96wnl - -# 可灵控制台 -https://console-cn.klingai.com/console/expense-center/resource-pack-manage - -# 登录 -18686619970 -获取验证码登录 diff --git a/dsAi/target/classes/com/dsideal/Res/Util/Liblib/Doc/文档.txt b/dsAi/target/classes/com/dsideal/Res/Util/Liblib/Doc/文档.txt deleted file mode 100644 index 814e0c5f..00000000 --- a/dsAi/target/classes/com/dsideal/Res/Util/Liblib/Doc/文档.txt +++ /dev/null @@ -1,39 +0,0 @@ -# 官网 -https://www.liblib.art/apis - -# 账号 -18686619970 -手机验证码登录 - -# 访问凭证 -AK: sOCtVLVTNOZkRMajlhzCmg -SK: PUe8QTRG9i0G9EbpedHmIpLQ0FyxoYY9 - - -# 接口文档 -https://liblibai.feishu.cn/wiki/UAMVw67NcifQHukf8fpccgS5n6d - - -计划 -API试用计划 -到期时间 -2025/05/22 23:59:59 -剩余积分 -500 -购买积分 -并发任务数 -1个 - - -# LiblibAI工作流 -社区商用工作流和个人本地工作流均可支持调用。工作流挑选和商用查询可至https://www.liblib.art/workflows - -# - 星流Star-3 Alpha:适合对AI生图参数不太了解或不想复杂控制的用户。搭载自带LoRA推荐算法,对自然语言的精准响应,提供极致的图像质量,能够生成具有照片级真实感的视觉效果,不能自由添加LoRA,仅支持部分ControlNet。生图效果可至星流官网https://xingliu.art/体验。 - -# - LiblibAI自定义模型:若需要特定LoRA和ControlNet只能选此模式,适合高度自由、精准控制和特定风格的场景,基于F.1/XL/v3/v1.5等基础算法,支持自定义调用LiblibAI内全量30万+可商用模型和任意私有模型。最新开源模型和插件第一时间更新。模型挑选和商用查询可至本文档3.1或https://www.liblib.art/。 - - -# 参考文档 -https://liblibai.feishu.cn/wiki/UAMVw67NcifQHukf8fpccgS5n6d - -https://www.liblib.art/workflows \ No newline at end of file diff --git a/dsAi/target/classes/com/dsideal/Res/Util/Liblib/Example/019dba57244f2682e672a8a1ce9d50536e85f130a1142d19755c8266d4a8577c.png b/dsAi/target/classes/com/dsideal/Res/Util/Liblib/Example/019dba57244f2682e672a8a1ce9d50536e85f130a1142d19755c8266d4a8577c.png deleted file mode 100644 index d554c372..00000000 Binary files a/dsAi/target/classes/com/dsideal/Res/Util/Liblib/Example/019dba57244f2682e672a8a1ce9d50536e85f130a1142d19755c8266d4a8577c.png and /dev/null differ diff --git a/dsAi/target/classes/com/dsideal/Res/Util/Liblib/Example/1e458ad4a7f30e853acff80f4723f42638c21205f0ff2d64898589dd994f1f94.png b/dsAi/target/classes/com/dsideal/Res/Util/Liblib/Example/1e458ad4a7f30e853acff80f4723f42638c21205f0ff2d64898589dd994f1f94.png deleted file mode 100644 index 6dbce122..00000000 Binary files a/dsAi/target/classes/com/dsideal/Res/Util/Liblib/Example/1e458ad4a7f30e853acff80f4723f42638c21205f0ff2d64898589dd994f1f94.png and /dev/null differ diff --git a/dsAi/target/classes/com/dsideal/Res/Util/Liblib/Example/53ea797eeb6f5adafdfdeb3fc9918e200fb8b716e1773cebe54535b36adb5134.png b/dsAi/target/classes/com/dsideal/Res/Util/Liblib/Example/53ea797eeb6f5adafdfdeb3fc9918e200fb8b716e1773cebe54535b36adb5134.png deleted file mode 100644 index 23a74482..00000000 Binary files a/dsAi/target/classes/com/dsideal/Res/Util/Liblib/Example/53ea797eeb6f5adafdfdeb3fc9918e200fb8b716e1773cebe54535b36adb5134.png and /dev/null differ diff --git a/dsAi/target/classes/com/dsideal/Res/Util/Liblib/Example/7d6679969e1c6e014d37710935c2603b40b7217e14bc5003ea2ca8331e9ef40d.png b/dsAi/target/classes/com/dsideal/Res/Util/Liblib/Example/7d6679969e1c6e014d37710935c2603b40b7217e14bc5003ea2ca8331e9ef40d.png deleted file mode 100644 index cb1d4ce3..00000000 Binary files a/dsAi/target/classes/com/dsideal/Res/Util/Liblib/Example/7d6679969e1c6e014d37710935c2603b40b7217e14bc5003ea2ca8331e9ef40d.png and /dev/null differ diff --git a/dsAi/target/classes/com/dsideal/Res/Util/Liblib/Example/TextToImageUltra.png b/dsAi/target/classes/com/dsideal/Res/Util/Liblib/Example/TextToImageUltra.png deleted file mode 100644 index a8b744c9..00000000 Binary files a/dsAi/target/classes/com/dsideal/Res/Util/Liblib/Example/TextToImageUltra.png and /dev/null differ diff --git a/dsAi/target/classes/com/dsideal/Res/Util/Midjourney/Doc/文档.txt b/dsAi/target/classes/com/dsideal/Res/Util/Midjourney/Doc/文档.txt deleted file mode 100644 index d7149319..00000000 --- a/dsAi/target/classes/com/dsideal/Res/Util/Midjourney/Doc/文档.txt +++ /dev/null @@ -1,3 +0,0 @@ -https://goapi.gptnb.ai/account/profile -littlehb -mdcija780522 \ No newline at end of file diff --git a/dsAi/target/classes/com/dsideal/aiSupport/Util/JiMeng/Example/Text2Img.jpg b/dsAi/target/classes/com/dsideal/aiSupport/Util/JiMeng/Example/Text2Img.jpg deleted file mode 100644 index 2238c6bf..00000000 Binary files a/dsAi/target/classes/com/dsideal/aiSupport/Util/JiMeng/Example/Text2Img.jpg and /dev/null differ diff --git a/dsBase/src/main/java/com/dsideal/Base/Dm/Controller/DmController.java b/dsBase/src/main/java/com/dsideal/Base/Dm/Controller/DmController.java index 69621b3c..4297c184 100644 --- a/dsBase/src/main/java/com/dsideal/Base/Dm/Controller/DmController.java +++ b/dsBase/src/main/java/com/dsideal/Base/Dm/Controller/DmController.java @@ -255,7 +255,7 @@ public class DmController extends Controller { area_name = record.getStr("area_name"); area_code = record.getStr("area_code"); is_leaf = record.getInt("is_leaf"); - last = is_leaf == 0 ? true : false; + last = is_leaf == 0; // 创建要添加的新节点 TDmArea newNode = new TDmArea(area_name, pId, area_code, id, is_leaf, false, last,level_id+1); rootNode.addChild(newNode); diff --git a/dsBase/src/main/java/com/dsideal/Base/Dm/Model/DmModel.java b/dsBase/src/main/java/com/dsideal/Base/Dm/Model/DmModel.java index d1dbccc0..3c12b4e7 100644 --- a/dsBase/src/main/java/com/dsideal/Base/Dm/Model/DmModel.java +++ b/dsBase/src/main/java/com/dsideal/Base/Dm/Model/DmModel.java @@ -40,7 +40,7 @@ public class DmModel { */ public Record getCityCoordinate(String city_id) { String sql = Db.getSql("dm.getCityCoordinate"); - return Db.find(sql, city_id).get(0); + return Db.find(sql, city_id).getFirst(); } /** @@ -226,40 +226,6 @@ public class DmModel { } } - /** - * 功能:根据上级代码ID,获取它的等级,市:1,县区:2,单位:3,部门:4,找不到是-1 - * - * @return - */ - public int getOrgLevel(String org_id) { - String sql = Db.getSql("dm.getOrgLevel"); - List records = Db.find(sql, org_id); - if (records.size() > 0) { - //如果org_id与parent_id一样的话,那么应该是单位 - if (records.get(0).getStr("parent_id").equals(org_id)) { - return 3; - } else//否则是部门 - { - return 4; - } - } - - //去行政区划表中查找 - sql = Db.getSql("dm.getAreaById"); - records = Db.find(sql, org_id); - - if (records.size() == 0) { - return -1; - } - if (records.get(0).getStr("city_id").equals(org_id)) { - return 1; - } else if (records.get(0).getStr("area_id").equals(org_id)) { - return 2; - } else { - return -1; - } - } - /** * 功能:获取学校类型 * 作者:黄海 @@ -312,15 +278,4 @@ public class DmModel { return Db.find(sql, area_id); } - /** - * 功能:获取当前安装地区下有哪些个县区 - * 作者:黄海 - * 时间:2019-01-08 - * - * @return - */ - public List getAllAreaInfoByInstallCity() { - String sql = Db.getSql("dm.getAllAreaInfoByInstallCity"); - return Db.find(sql); - } } diff --git a/dsBase/src/main/java/com/dsideal/Base/Plugin/RedisCluster.java b/dsBase/src/main/java/com/dsideal/Base/Plugin/RedisCluster.java deleted file mode 100644 index 441d70e7..00000000 --- a/dsBase/src/main/java/com/dsideal/Base/Plugin/RedisCluster.java +++ /dev/null @@ -1,184 +0,0 @@ -package com.dsideal.Base.Plugin; - -import java.util.concurrent.ConcurrentHashMap; -import java.util.logging.Logger; -import java.util.logging.Level; - -import redis.clients.jedis.JedisCluster; - -import com.jfinal.kit.StrKit; - -/** - * Redis集群工具类 - * 提供Redis集群缓存的管理功能,支持多个集群缓存的添加、删除和使用 - * - * @author 石啸天 - * @version 1.0 - * @since 1.0 - */ -public class RedisCluster { - - private static final Logger LOGGER = Logger.getLogger(RedisCluster.class.getName()); - - /** - * 主集群缓存 - * 使用volatile确保多线程环境下的可见性 - */ - private static volatile JedisCluster mainCache = null; - - /** - * 集群缓存集合 - * 使用ConcurrentHashMap确保线程安全 - */ - private static final ConcurrentHashMap cacheMap = new ConcurrentHashMap<>(); - - /** - * 插入新集群缓存 - * - * @param cacheName 集群缓存名称,不能为空或空白字符串 - * @param cache 集群缓存实例,不能为null - * @throws IllegalArgumentException 当参数无效时抛出 - */ - public static synchronized void addCache(String cacheName, JedisCluster cache) { - // 参数验证 - if (cache == null) { - throw new IllegalArgumentException("cache can not be null"); - } - if (StrKit.isBlank(cacheName)) { - throw new IllegalArgumentException("cacheName can not be blank"); - } - - cacheName = cacheName.trim(); - if (cacheMap.containsKey(cacheName)) { - throw new IllegalArgumentException("The cache name already exists: " + cacheName); - } - - cacheMap.put(cacheName, cache); - - // 如果主缓存未设置,将当前缓存设为主缓存 - if (mainCache == null) { - mainCache = cache; - LOGGER.info("Set main cache to: " + cacheName); - } - - LOGGER.info("Added cache: " + cacheName); - } - - /** - * 删除集群缓存 - * - * @param cacheName 集群缓存名称,不能为空或空白字符串 - * @return 被删除的JedisCluster实例,如果不存在则返回null - * @throws IllegalArgumentException 当cacheName为空或空白时抛出 - */ - public static synchronized JedisCluster removeCache(String cacheName) { - if (StrKit.isBlank(cacheName)) { - throw new IllegalArgumentException("cacheName can not be blank"); - } - - cacheName = cacheName.trim(); - JedisCluster removedCache = cacheMap.remove(cacheName); - - // 如果删除的是主缓存,需要重新设置主缓存 - if (removedCache != null && removedCache == mainCache) { - mainCache = cacheMap.isEmpty() ? null : cacheMap.values().iterator().next(); - LOGGER.info("Removed main cache, reset main cache to: " + - (mainCache == null ? "null" : "first available cache")); - } - - if (removedCache != null) { - LOGGER.info("Removed cache: " + cacheName); - } else { - LOGGER.warning("Cache not found for removal: " + cacheName); - } - - return removedCache; - } - - /** - * 设置主集群缓存 - * 提供一个设置主集群缓存mainCache的机会,否则第一个被初始化的Cache将成为mainCache - * - * @param cacheName 要设置为主缓存的集群缓存名称,不能为空或空白字符串 - * @throws IllegalArgumentException 当cacheName为空、空白或对应的缓存不存在时抛出 - */ - public static synchronized void setMainCache(String cacheName) { - if (StrKit.isBlank(cacheName)) { - throw new IllegalArgumentException("cacheName can not be blank"); - } - - cacheName = cacheName.trim(); - JedisCluster cache = cacheMap.get(cacheName); - if (cache == null) { - throw new IllegalArgumentException("the cache not exists: " + cacheName); - } - - mainCache = cache; - LOGGER.info("Set main cache to: " + cacheName); - } - - /** - * 使用主集群缓存 - * - * @return 主集群缓存实例,如果未设置则返回null - * @throws IllegalStateException 当主缓存未初始化时抛出 - */ - public static JedisCluster use() { - if (mainCache == null) { - throw new IllegalStateException("Main cache is not initialized. Please add at least one cache first."); - } - return mainCache; - } - - /** - * 使用指定名称的集群缓存 - * - * @param cacheName 集群缓存名称,不能为空或空白字符串 - * @return 指定名称的JedisCluster实例,如果不存在则返回null - * @throws IllegalArgumentException 当cacheName为空或空白时抛出 - */ - public static JedisCluster use(String cacheName) { - if (StrKit.isBlank(cacheName)) { - throw new IllegalArgumentException("cacheName can not be blank"); - } - - cacheName = cacheName.trim(); - JedisCluster cache = cacheMap.get(cacheName); - - if (cache == null) { - LOGGER.warning("Cache not found: " + cacheName); - } - - return cache; - } - - /** - * 获取当前缓存数量 - * - * @return 当前管理的缓存数量 - */ - public static int getCacheCount() { - return cacheMap.size(); - } - - /** - * 检查指定名称的缓存是否存在 - * - * @param cacheName 缓存名称 - * @return 如果存在返回true,否则返回false - */ - public static boolean containsCache(String cacheName) { - if (StrKit.isBlank(cacheName)) { - return false; - } - return cacheMap.containsKey(cacheName.trim()); - } - - /** - * 私有构造函数,防止实例化 - */ - private RedisCluster() { - throw new UnsupportedOperationException("Utility class cannot be instantiated"); - } - -} diff --git a/dsBase/src/main/java/com/dsideal/Base/Plugin/RedisClusterPlugin.java b/dsBase/src/main/java/com/dsideal/Base/Plugin/RedisClusterPlugin.java deleted file mode 100644 index c54cfab6..00000000 --- a/dsBase/src/main/java/com/dsideal/Base/Plugin/RedisClusterPlugin.java +++ /dev/null @@ -1,316 +0,0 @@ -package com.dsideal.Base.Plugin; - -import java.util.Set; -import java.util.logging.Logger; -import java.util.logging.Level; - -import org.apache.commons.pool2.impl.GenericObjectPoolConfig; - -import redis.clients.jedis.HostAndPort; -import redis.clients.jedis.JedisCluster; - -import com.jfinal.kit.StrKit; -import com.jfinal.plugin.IPlugin; - -/** - * 为JFinal框架下的Redis集群提供插件方案 - *

- * 支持的版本信息: - *

    - *
  • JFinal版本号 2.1+
  • - *
  • Jedis版本号 2.7.2+
  • - *
  • commons-pool2版本号 2.3+
  • - *
- *

- * 依赖包要求: - *

    - *
  • jedis-2.7.2.jar或更高版本
  • - *
  • commons-pool2-2.3.jar或更高版本
  • - *
- * - * @author 石啸天 - * @version 1.0 - * @since 1.0 - */ -public class RedisClusterPlugin implements IPlugin { - - private static final Logger LOGGER = Logger.getLogger(RedisClusterPlugin.class.getName()); - - /** - * 默认超时时间(毫秒) - */ - private static final int DEFAULT_TIMEOUT = 2000; - - /** - * 默认最大重定向次数 - */ - private static final int DEFAULT_MAX_REDIRECTIONS = 5; - - /** - * 集群名称 - */ - private final String clusterName; - - /** - * 集群对象 - */ - private JedisCluster jedisCluster; - - /** - * 超时时间(毫秒) - */ - private final Integer timeout; - - /** - * 连接池配置 - */ - private final GenericObjectPoolConfig poolConfig; - - /** - * 最多重定向次数 - */ - private final Integer maxRedirections; - - /** - * 集群地址集合 - */ - private final Set redisClusterNodes; - - /** - * 基础构造函数 - * - * @param clusterName 集群名称,不能为空或空白字符串 - * @param redisClusterNodes 集群地址集合,不能为空且至少包含一个有效地址 - * @throws IllegalArgumentException 当参数无效时抛出 - */ - public RedisClusterPlugin(String clusterName, Set redisClusterNodes) { - this(clusterName, redisClusterNodes, null, null, null); - } - - /** - * 带超时时间的构造函数 - * - * @param clusterName 集群名称,不能为空或空白字符串 - * @param redisClusterNodes 集群地址集合,不能为空且至少包含一个有效地址 - * @param timeout 超时时间(毫秒),为null时使用默认值 - * @throws IllegalArgumentException 当参数无效时抛出 - */ - public RedisClusterPlugin(String clusterName, Set redisClusterNodes, Integer timeout) { - this(clusterName, redisClusterNodes, timeout, null, null); - } - - /** - * 带连接池配置的构造函数 - * - * @param clusterName 集群名称,不能为空或空白字符串 - * @param redisClusterNodes 集群地址集合,不能为空且至少包含一个有效地址 - * @param poolConfig 连接池配置对象,为null时使用默认配置 - * @throws IllegalArgumentException 当参数无效时抛出 - */ - public RedisClusterPlugin(String clusterName, Set redisClusterNodes, GenericObjectPoolConfig poolConfig) { - this(clusterName, redisClusterNodes, null, null, poolConfig); - } - - /** - * 带超时时间和连接池配置的构造函数 - * - * @param clusterName 集群名称,不能为空或空白字符串 - * @param redisClusterNodes 集群地址集合,不能为空且至少包含一个有效地址 - * @param timeout 超时时间(毫秒),为null时使用默认值 - * @param poolConfig 连接池配置对象,为null时使用默认配置 - * @throws IllegalArgumentException 当参数无效时抛出 - */ - public RedisClusterPlugin(String clusterName, Set redisClusterNodes, Integer timeout, GenericObjectPoolConfig poolConfig) { - this(clusterName, redisClusterNodes, timeout, null, poolConfig); - } - - /** - * 带超时时间和最大重定向次数的构造函数 - * - * @param clusterName 集群名称,不能为空或空白字符串 - * @param redisClusterNodes 集群地址集合,不能为空且至少包含一个有效地址 - * @param timeout 超时时间(毫秒),为null时使用默认值 - * @param maxRedirections 最大重定向次数,为null时使用默认值 - * @throws IllegalArgumentException 当参数无效时抛出 - */ - public RedisClusterPlugin(String clusterName, Set redisClusterNodes, Integer timeout, Integer maxRedirections) { - this(clusterName, redisClusterNodes, timeout, maxRedirections, null); - } - - /** - * 完整参数的构造函数 - * - * @param clusterName 集群名称,不能为空或空白字符串 - * @param redisClusterNodes 集群地址集合,不能为空且至少包含一个有效地址 - * @param timeout 超时时间(毫秒),为null时使用默认值 - * @param maxRedirections 最大重定向次数,为null时使用默认值 - * @param poolConfig 连接池配置对象,为null时使用默认配置 - * @throws IllegalArgumentException 当参数无效时抛出 - */ - public RedisClusterPlugin(String clusterName, Set redisClusterNodes, Integer timeout, Integer maxRedirections, GenericObjectPoolConfig poolConfig) { - // 验证参数 - validateParameters(clusterName, redisClusterNodes); - - // 初始化字段 - this.clusterName = clusterName.trim(); - this.redisClusterNodes = redisClusterNodes; - this.timeout = timeout; - this.maxRedirections = maxRedirections; - this.poolConfig = poolConfig; - - LOGGER.info("RedisClusterPlugin initialized for cluster: " + this.clusterName); - } - - /** - * 启动Redis集群插件 - * 根据配置参数创建JedisCluster实例并注册到RedisCluster管理器中 - * - * @return 启动成功返回true,失败返回false - */ - @Override - public boolean start() { - try { - // 根据配置参数创建JedisCluster实例 - jedisCluster = createJedisCluster(); - - // 将集群实例注册到RedisCluster管理器中 - RedisCluster.addCache(clusterName, jedisCluster); - - LOGGER.info("Redis cluster plugin started successfully for: " + clusterName); - return true; - - } catch (Exception e) { - LOGGER.log(Level.SEVERE, "Failed to start Redis cluster plugin for: " + clusterName, e); - return false; - } - } - - /** - * 根据配置参数创建JedisCluster实例 - * - * @return JedisCluster实例 - */ - private JedisCluster createJedisCluster() { - // 使用有效的超时时间 - int effectiveTimeout = (timeout != null) ? timeout : DEFAULT_TIMEOUT; - - // 使用有效的最大重定向次数 - int effectiveMaxRedirections = (maxRedirections != null) ? maxRedirections : DEFAULT_MAX_REDIRECTIONS; - - // 根据参数组合创建JedisCluster实例 - if (poolConfig != null) { - if (timeout != null && maxRedirections != null) { - return new JedisCluster(redisClusterNodes, effectiveTimeout, effectiveMaxRedirections, poolConfig); - } else if (timeout != null) { - return new JedisCluster(redisClusterNodes, effectiveTimeout, poolConfig); - } else { - return new JedisCluster(redisClusterNodes, poolConfig); - } - } else { - if (timeout != null && maxRedirections != null) { - return new JedisCluster(redisClusterNodes, effectiveTimeout, effectiveMaxRedirections); - } else if (timeout != null) { - return new JedisCluster(redisClusterNodes, effectiveTimeout); - } else { - return new JedisCluster(redisClusterNodes); - } - } - } - - /** - * 停止Redis集群插件 - * 从RedisCluster管理器中移除集群实例并关闭连接 - * - * @return 停止成功返回true,失败返回false - */ - @Override - public boolean stop() { - try { - // 从集群管理器中移除集群实例 - JedisCluster removedCluster = RedisCluster.removeCache(clusterName); - - // 关闭集群连接 - if (removedCluster != null) { - removedCluster.close(); - LOGGER.info("Redis cluster plugin stopped successfully for: " + clusterName); - } else { - LOGGER.warning("Redis cluster not found when stopping: " + clusterName); - } - - // 清理本地引用 - jedisCluster = null; - - return true; - - } catch (Exception e) { - LOGGER.log(Level.SEVERE, "Failed to stop Redis cluster plugin for: " + clusterName, e); - return false; - } - } - - /** - * 验证传入的集群参数是否正确 - * - * @param clusterName 集群名称 - * @param redisClusterNodes 集群地址集合 - * @throws IllegalArgumentException 当参数无效时抛出 - */ - private void validateParameters(String clusterName, Set redisClusterNodes) { - // 验证集群名称 - if (StrKit.isBlank(clusterName)) { - throw new IllegalArgumentException("clusterName can not be blank"); - } - - // 验证集群节点集合 - if (redisClusterNodes == null || redisClusterNodes.isEmpty()) { - throw new IllegalArgumentException("redisClusterNodes can not be null or empty"); - } - - // 验证每个节点的主机和端口信息 - for (HostAndPort hostAndPort : redisClusterNodes) { - if (hostAndPort == null) { - throw new IllegalArgumentException("HostAndPort in redisClusterNodes can not be null"); - } - - // 验证主机地址 - String host = hostAndPort.getHost(); - if (StrKit.isBlank(host)) { - throw new IllegalArgumentException("host can not be blank"); - } - - // 验证端口号 - int port = hostAndPort.getPort(); - if (port <= 0 || port > 65535) { - throw new IllegalArgumentException("port must be between 1 and 65535, but got: " + port); - } - } - } - - /** - * 获取集群名称 - * - * @return 集群名称 - */ - public String getClusterName() { - return clusterName; - } - - /** - * 获取JedisCluster实例 - * - * @return JedisCluster实例,如果插件未启动则返回null - */ - public JedisCluster getJedisCluster() { - return jedisCluster; - } - - /** - * 检查插件是否已启动 - * - * @return 如果插件已启动返回true,否则返回false - */ - public boolean isStarted() { - return jedisCluster != null; - } - -} \ No newline at end of file diff --git a/dsBase/src/main/java/com/dsideal/Base/Util/CookieUtil.java b/dsBase/src/main/java/com/dsideal/Base/Util/CookieUtil.java index aba828f5..98b77b1b 100644 --- a/dsBase/src/main/java/com/dsideal/Base/Util/CookieUtil.java +++ b/dsBase/src/main/java/com/dsideal/Base/Util/CookieUtil.java @@ -21,7 +21,7 @@ public class CookieUtil { private static Cookie get(HttpServletRequest request, String key) { Cookie[] arr_cookie = request.getCookies(); - if (arr_cookie != null && arr_cookie.length > 0) { + if (arr_cookie != null) { for (Cookie cookie : arr_cookie) { if (cookie.getName().equals(key)) { return cookie; diff --git a/dsBase/src/main/java/com/dsideal/Base/Util/ExcelCommonUtil.java b/dsBase/src/main/java/com/dsideal/Base/Util/ExcelCommonUtil.java index 0ac1c081..4d29de3a 100644 --- a/dsBase/src/main/java/com/dsideal/Base/Util/ExcelCommonUtil.java +++ b/dsBase/src/main/java/com/dsideal/Base/Util/ExcelCommonUtil.java @@ -25,7 +25,6 @@ import java.util.*; public class ExcelCommonUtil { /** - * https://fireinwind.iteye.com/blog/2168655 * 功能:通用的导出excel功能 * 作者:黄海 * 时间:2018-12-12 diff --git a/dsBase/src/main/java/com/dsideal/Base/Util/ExcelExportUtil.java b/dsBase/src/main/java/com/dsideal/Base/Util/ExcelExportUtil.java index d4fc9dc2..ba37f3e8 100644 --- a/dsBase/src/main/java/com/dsideal/Base/Util/ExcelExportUtil.java +++ b/dsBase/src/main/java/com/dsideal/Base/Util/ExcelExportUtil.java @@ -10,7 +10,6 @@ import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellRangeAddress; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; import java.io.File; import java.io.FileNotFoundException; @@ -343,71 +342,4 @@ public class ExcelExportUtil { return hssfWorkbook; } - public static void exportByTemplate(List list, String template, String excelFile) throws IOException { - XSSFWorkbook workbook = new XSSFWorkbook(template); - // 获取第一个工作表(工作表索引从0开始) - Sheet sheet = workbook.getSheetAt(0); - - //数据开始行 - int startRow = sheet.getLastRowNum(); - //一共多少列 - int colNum = sheet.getRow(0).getLastCellNum(); - - Font txtFont = workbook.createFont(); - txtFont.setFontHeightInPoints((short) 14); //字体大小 - txtFont.setFontName("宋体"); //字体 - CellStyle cellStyleTxt = workbook.createCellStyle(); - cellStyleTxt.setFont(txtFont); - cellStyleTxt.setAlignment(HorizontalAlignment.CENTER); - cellStyleTxt.setFillForegroundColor(IndexedColors.LIME.getIndex()); - cellStyleTxt.setWrapText(true);//设置自动换行 - cellStyleTxt.setVerticalAlignment(VerticalAlignment.CENTER); - cellStyleTxt.setBorderBottom(BorderStyle.THIN); // 底部边框 - cellStyleTxt.setBorderLeft(BorderStyle.THIN); // 左边边框 - cellStyleTxt.setBorderRight(BorderStyle.THIN); // 右边边框 - cellStyleTxt.setBorderTop(BorderStyle.THIN); // 上边边框 - - //导出数据 - int count = startRow; - //每一行数据的高度 - short rowHeight = 28 * 20; - //最后一行是数据与字段的关系,先读取出来 - Row row = sheet.getRow(startRow); - Map _map = new HashMap<>(); - for (int i = 0; i < colNum; i++) { - Cell cell = row.getCell(i); - _map.put(i, cell.getStringCellValue()); - } - //删除最后一行 - sheet.removeRow(row); - - for (int i = 0; i < list.size(); i++) { - row = sheet.createRow(count++); - Record record = list.get(i); - for (int j = 0; j < colNum; j++) { - Cell cell = row.createCell(j); - cell.setCellStyle(cellStyleTxt); - - if (_map.get(j).equals("{{num}}")) { - cell.setCellValue(i + 1); - } else { - cell.setCellValue(record.getStr(_map.get(j))); - } - row.setHeight(rowHeight); - } - } - - //生成文件 - File file = new File(excelFile); - try { - FileOutputStream fileOutputStreane = new FileOutputStream(file); - workbook.write(fileOutputStreane); - fileOutputStreane.flush(); - fileOutputStreane.close(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - } } diff --git a/dsBase/src/main/java/com/dsideal/Base/Util/IpUtil.java b/dsBase/src/main/java/com/dsideal/Base/Util/IpUtil.java index 83bb8302..bbdc3f53 100644 --- a/dsBase/src/main/java/com/dsideal/Base/Util/IpUtil.java +++ b/dsBase/src/main/java/com/dsideal/Base/Util/IpUtil.java @@ -14,19 +14,19 @@ public class IpUtil { */ public static String getIpAddr(HttpServletRequest request) { String ip = request.getHeader("X-Forwarded-For"); - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + if (ip == null || ip.isEmpty() || "unknown".equalsIgnoreCase(ip)) { ip = request.getHeader("Proxy-Client-IP"); } - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + if (ip == null || ip.isEmpty() || "unknown".equalsIgnoreCase(ip)) { ip = request.getHeader("WL-Proxy-Client-IP"); } - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + if (ip == null || ip.isEmpty() || "unknown".equalsIgnoreCase(ip)) { ip = request.getHeader("HTTP_CLIENT_IP"); } - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + if (ip == null || ip.isEmpty() || "unknown".equalsIgnoreCase(ip)) { ip = request.getHeader("HTTP_X_FORWARDED_FOR"); } - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + if (ip == null || ip.isEmpty() || "unknown".equalsIgnoreCase(ip)) { ip = request.getRemoteAddr(); } return ip; @@ -39,10 +39,9 @@ public class IpUtil { for (int i = 0; i < 4; ++i) { ipNums.add(Long.parseLong(ipArray[i].trim())); } - long ZhongIPNumTotal = ipNums.get(0) * 256L * 256L * 256L + + return ipNums.get(0) * 256L * 256L * 256L + ipNums.get(1) * 256L * 256L + ipNums.get(2) * 256L + ipNums.get(3); - - return ZhongIPNumTotal; } } diff --git a/dsBase/src/main/java/com/dsideal/Base/Util/PgSqlUtil.java b/dsBase/src/main/java/com/dsideal/Base/Util/PgSqlUtil.java deleted file mode 100644 index 2ebee9b6..00000000 --- a/dsBase/src/main/java/com/dsideal/Base/Util/PgSqlUtil.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.dsideal.Base.Util; - -import com.jfinal.kit.StrKit; -import com.jfinal.plugin.activerecord.Db; -import com.jfinal.plugin.activerecord.Record; - -public class PgSqlUtil { - protected static String getPkColumnName(String table_name) { - String sql="select pk_name,colname from v_pk_name where relname=?"; - Record record= Db.findFirst(sql,table_name); - if (record == null) return null; - return record.getStr("colname"); - } - - protected static String getSeqNameByTableName(String table_name) { - String pkName = getPkColumnName(table_name); - if (pkName == null) { - System.out.println("表" + table_name + "不存在主键,无法执行truncate!"); - } - if (!pkName.equals(null)) { - String sql = "SELECT pg_get_serial_sequence(?,?) as sq_name"; - String sqName = Db.findFirst(sql, table_name, pkName).getStr("sq_name"); - if (StrKit.isBlank(sqName)) return null; - return sqName.replace("public.", ""); - } - return null; - } - - public static void Truncate(String table_name) { - String sql = "truncate table " + table_name; - System.out.println(sql); - Db.update(sql); - - String seq_name = getSeqNameByTableName(table_name); - if (!StrKit.isBlank(seq_name)) { - sql = "SELECT setval('" + seq_name + "', 1, false);"; - Db.find(sql); - } - } - - public static void DelAll(String table_name) { - String sql = "delete from " + table_name; - Db.update(sql); - } -} \ No newline at end of file diff --git a/dsBase/src/main/java/com/dsideal/Base/Util/PgUtil.java b/dsBase/src/main/java/com/dsideal/Base/Util/PgUtil.java deleted file mode 100644 index 97ff07a9..00000000 --- a/dsBase/src/main/java/com/dsideal/Base/Util/PgUtil.java +++ /dev/null @@ -1,124 +0,0 @@ -package com.dsideal.Base.Util; - -import com.jfinal.kit.Kv; -import com.jfinal.plugin.activerecord.Db; -import com.jfinal.plugin.activerecord.Record; -import com.jfinal.plugin.activerecord.SqlPara; - -import java.util.List; - -public class PgUtil { - - /** - * 功能:获取用户有哪些权限 - * - * @param user_name - * @return - */ - public static List getUserPrivilege(String user_name) { - Kv kv = Kv.by("user_name", user_name); - SqlPara sqlPara = Db.getSqlPara("PG.getUserPrivilage", kv); - return Db.find(sqlPara); - } - - /** - * 功能:删除用户 - * - * @param user_name - */ - public static void delUser(String user_name) { - //需要先回收用户的权限 - List list = PgUtil.getUserPrivilege(user_name); - for (Record record : list) { - String table_name = record.getStr("table_name"); - String privilege = record.getStr("privilege_type"); - PgUtil.revokeUserPrivilege(user_name, table_name, privilege); - } - // 删除用户 - String sql = "DROP USER " + user_name; - Db.update(sql); - } - - /** - * 功能:创建用户 - * - * @param user_name - * @param pwd - */ - public static void createUser(String user_name, String pwd) { - String sql = "CREATE USER " + user_name + " WITH PASSWORD '" + pwd + "'"; - Db.update(sql); - } - - /** - * 功能:判断用户是否存在 - * - * @param user_name - * @return - */ - public static boolean isExistUser(String user_name) { - String sql = "SELECT * FROM pg_user WHERE usename = ?"; - List list = Db.find(sql, user_name); - return !list.isEmpty(); - } - - - /** - * 功能:授予用户权限 - * - * @param user_name - * @param table_name - */ - public static void grantUserPrivilege(String user_name, String table_name, String privilege) { - String sql = "GRANT " + privilege + " ON " + table_name + " TO " + user_name; - Db.update(sql); - //System.out.println("成功授予用户:" + user_name + ",表" + table_name + "的" + privilege + "权限!"); - } - - /** - * 功能:回收用户权限 - * - * @param user_name - * @param table_name - */ - public static void revokeUserPrivilege(String user_name, String table_name, String privilege) { - String sql = "REVOKE " + privilege + " ON " + table_name + " from " + user_name; - Db.update(sql); - } - - /** - * 功能:判断一个表是不是存在 - * - * @param table_name - * @return - */ - public static boolean isExistTable(String table_name) { - String sql = "SELECT count(1) as c FROM pg_tables WHERE tablename = ?"; - int sum = Db.findFirst(sql, table_name).getInt("c"); - if (sum > 0) return true; - //如果是视图 - sql = "select count(1) as c from pg_views WHERE viewname = ?"; - sum = Db.findFirst(sql, table_name).getInt("c"); - return sum > 0; - } - - /** - * 功能:修改用户密码 - * - * @param user_name - * @param pwd - */ - public static void changePwd(String user_name, String pwd) { - String sql = "ALTER USER " + user_name + " WITH PASSWORD '" + pwd + "'"; - Db.update(sql); - } - - //写权限 - public static String WRITE = "INSERT,UPDATE,DELETE,SELECT"; - //读权限 - public static String READ = "SELECT"; - - - - -} diff --git a/dsBase/src/main/java/com/dsideal/Base/Util/PoiUtil.java b/dsBase/src/main/java/com/dsideal/Base/Util/PoiUtil.java deleted file mode 100644 index 388c9f5e..00000000 --- a/dsBase/src/main/java/com/dsideal/Base/Util/PoiUtil.java +++ /dev/null @@ -1,403 +0,0 @@ -package com.dsideal.Base.Util; - -import org.apache.poi.ss.usermodel.*; -import org.apache.poi.ss.usermodel.DateUtil; -import org.apache.poi.ss.util.CellRangeAddress; -import org.apache.poi.ss.util.CellRangeAddressList; -import org.apache.poi.xssf.usermodel.*; - -import java.io.*; -import java.math.BigDecimal; -import java.text.SimpleDateFormat; -import java.util.*; - -public class PoiUtil { - - /** - * 功能:对于指定Cell中文字进行加红色(*)提醒 - * - * @param wb - * @param cell - */ - public static void addStar(XSSFWorkbook wb, XSSFCell cell) { - XSSFFont fontRed = wb.createFont();//第一种字体 - fontRed.setBold(true); - fontRed.setColor(IndexedColors.RED.getIndex()); - fontRed.setFontHeightInPoints((short) 14); - fontRed.setFontName("黑体"); - - XSSFFont fontBlack = wb.createFont();//第二种字体 - fontBlack.setColor(IndexedColors.BLACK.getIndex()); - fontBlack.setFontName("宋体"); - fontRed.setBold(true); - fontBlack.setFontHeightInPoints((short) 12); - String txt = cell.getStringCellValue(); - - int len = txt.length(); - if (len == 0) { - System.out.println(cell.getSheet().getSheetName()); - System.out.println(cell.getRowIndex() + " " + cell.getColumnIndex()); - System.out.println(cell.getStringCellValue()); - System.out.println("发现问题:" + txt); - System.exit(0); - } - - txt += "(*)"; - XSSFRichTextString richText = new XSSFRichTextString(txt);//全部文字 - - richText.applyFont(0, len, fontBlack); // 从第0个字符到第2个字符应用font1 - richText.applyFont(len, len + 3, fontRed); // 从第2个字符到第4个字符应用font2 - cell.setCellValue(richText);//设置文字 - } - - - /** - * 功能:只改变单元格的颜色,其它的样式继承原来的样式 - * - * @param cell - * @param colorIdx - */ - public static void changeColor(Cell cell, short colorIdx) { - // 创建单元格样式 - CellStyle style = cell.getCellStyle(); - // 设置背景颜色 - style.setFillForegroundColor(colorIdx); - style.setFillPattern(FillPatternType.SOLID_FOREGROUND); - // 应用样式到单元格 - cell.setCellStyle(style); - } - - /** - * 功能:移除所有批注信息 - * - * @param sheet - */ - public static void RemoveAllComment(XSSFSheet sheet) { - // 遍历所有行和单元格,移除批注 - for (Row row : sheet) { - for (Cell cell : row) { - if (cell.getCellComment() != null) { - cell.removeCellComment(); - } - } - } - } - - /** - * 功能:将指定Sheet表中所有数据区域进行样式还原 - * - * @param sheet - */ - public static void resetStyle(XSSFSheet sheet, int dataStartRow) { - // 遍历所有行和单元格,恢复颜色 - for (int row = dataStartRow; row <= sheet.getLastRowNum(); row++) { - for (int col = 0; col < sheet.getRow(row).getLastCellNum(); col++) { - Cell cell = sheet.getRow(row).getCell(col); - // 创建单元格样式 - CellStyle style = cell.getCellStyle(); - // 设置背景颜色 - style.setFillForegroundColor(IndexedColors.WHITE.getIndex()); - style.setFillPattern(FillPatternType.SOLID_FOREGROUND); - // 应用样式到单元格 - cell.setCellStyle(style); - } - } - } - - /** - * 功能:修改指定单元格的样式 - * - * @param wb - * @return - */ - public static void addComment(Workbook wb, Cell cell, String str) { - Sheet sheet = cell.getSheet(); - // 判断单元格上是否存在批注 - if (cell.getCellComment() != null) { - // 如果存在批注,先删除 - cell.removeCellComment(); - } - // 创建批注 - Drawing drawing = sheet.createDrawingPatriarch(); - CreationHelper factory = wb.getCreationHelper(); - ClientAnchor anchor = factory.createClientAnchor(); - anchor.setCol1(cell.getColumnIndex()); - anchor.setCol2(cell.getColumnIndex() + 2); - anchor.setRow1(cell.getRow().getRowNum()); - anchor.setRow2(cell.getRow().getRowNum() + 3); - Comment comment = drawing.createCellComment(anchor); - comment.setString(factory.createRichTextString(str)); - // 将批注添加到单元格 - cell.setCellComment(comment); - } - - /** - * 功能:在EXCEL的指定范围内添加上下拉框,内容通过String[]提供 - * - * @param workbook - * @param sheetIdx - * @param firstRow - * @param lastRow - * @param firstCol - * @param lastCol - * @return - */ - public static void addValidation(Workbook workbook, int sheetIdx, String options, int firstRow, int lastRow, int firstCol, int lastCol) { - String[] optionArray = options.split(","); - Sheet sheet = workbook.getSheetAt(sheetIdx); - - // 删除已有的校验 - DataValidationHelper dvHelper = sheet.getDataValidationHelper(); - DataValidationConstraint dvConstraint = dvHelper.createCustomConstraint("DELETE_ALL"); - CellRangeAddressList addressList = new CellRangeAddressList(0, 0, 0, 0); // 设置一个范围,例如整个表格范围 - DataValidation validation = dvHelper.createValidation(dvConstraint, addressList); - validation.setSuppressDropDownArrow(true); - sheet.addValidationData(validation); - - // 创建数据验证对象 - DataValidationHelper validationHelper = sheet.getDataValidationHelper(); - DataValidationConstraint constraint = validationHelper.createExplicitListConstraint(optionArray); - addressList = new CellRangeAddressList(firstRow, lastRow, firstCol, lastCol); // 指定单元格范围 - validation = validationHelper.createValidation(constraint, addressList); - // 应用数据验证到单元格 - sheet.addValidationData(validation); - } - - /** - * 功能:获取指定Cell的内容值 - * - * @param cell - * @return - */ - //获取单元格各类型值,返回字符串类型 - public static String getValue(Cell cell) { - //判断是否为null或空串 - if (cell == null || cell.toString().trim().equals("")) { - return ""; - } - String cellValue = ""; - switch (cell.getCellType()) { - case NUMERIC: // 数字 - short format = cell.getCellStyle().getDataFormat(); - if (DateUtil.isCellDateFormatted(cell)) { - SimpleDateFormat sdf = null; - //System.out.println("cell.getCellStyle().getDataFormat()="+cell.getCellStyle().getDataFormat()); - if (format == 20 || format == 32) { - sdf = new SimpleDateFormat("HH:mm"); - } else if (format == 14 || format == 31 || format == 57 || format == 58) { - // 处理自定义日期格式:m月d日(通过判断单元格的格式id解决,id的值是58) - sdf = new SimpleDateFormat("yyyy-MM-dd"); - double value = cell.getNumericCellValue(); - Date date = org.apache.poi.ss.usermodel.DateUtil - .getJavaDate(value); - cellValue = sdf.format(date); - } else {// 日期 - sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - } - try { - cellValue = sdf.format(cell.getDateCellValue());// 日期 - } catch (Exception e) { - try { - throw new Exception("exception on get date data !".concat(e.toString())); - } catch (Exception e1) { - e1.printStackTrace(); - } - } finally { - sdf = null; - } - } else { - BigDecimal bd = new BigDecimal(cell.getNumericCellValue()); - cellValue = bd.toPlainString();// 数值 这种用BigDecimal包装再获取plainString,可以防止获取到科学计数值 - } - break; - case STRING: // 字符串 - cellValue = cell.getStringCellValue(); - break; - case BOOLEAN: // Boolean - cellValue = cell.getBooleanCellValue() + ""; - break; - case FORMULA: // 公式 - cellValue = cell.getCellFormula(); - break; - case BLANK: // 空值 - cellValue = ""; - break; - case ERROR: // 故障 - cellValue = "ERROR VALUE"; - break; - default: - cellValue = "UNKNOW VALUE"; - break; - } - return cellValue; - } - - /** - * 功能:判断一个单元格是不是被合并了 - * - * @param sheet - * @return - */ - public static boolean isMerged(XSSFSheet sheet, XSSFCell cell) { - // 判断单元格是否被合并 - for (CellRangeAddress range : sheet.getMergedRegions()) { - if (cell.getRowIndex() >= range.getFirstRow() && cell.getRowIndex() <= range.getLastRow() - && cell.getColumnIndex() >= range.getFirstColumn() && cell.getColumnIndex() <= range.getLastColumn()) { - return true; - } - } - return false; - } - - /** - * ) - * 获取单元格vo - * - * @param cell 单元格 - * @return - */ - public static String getColor(XSSFCell cell) { - if (cell != null) { - //背景颜色 - CellStyle cellStyle = cell.getCellStyle(); - XSSFColor xssfColor = (XSSFColor) cellStyle.getFillForegroundColorColor(); - byte[] bytes; - if (xssfColor != null) { - bytes = xssfColor.getRGB(); - return String.format("#%02X%02X%02X", bytes[0], bytes[1], bytes[2]); - } - } - return "BLANK"; - } - - /** - * 功能:查找指定Sheet中的表头开始位置与结束位置,目前只支持一个Sheet一个导入模板,并且,只支持单行或双行表头 - * - * @param sheet - * @return - */ - public static List getHead(XSSFSheet sheet) { - List list = new ArrayList<>(); - //整行都是同一种非空白颜色,视为表头 - // 遍历行 - for (int i = 0; i <= sheet.getLastRowNum(); i++) { - //获得行 - XSSFRow row = sheet.getRow(i); - //遍历列 - if (row != null) { - Map _map = new HashMap<>(); - for (int j = 0; j < row.getLastCellNum(); j++) { - //获取单元格 - XSSFCell cell = row.getCell(j); - if (cell == null) continue; - String color = getColor(cell); - //记录背景颜色数量 - if (_map.containsKey(color)) - _map.put(color, _map.get(color) + 1); - else - _map.put(color, 1); - } - if (_map.size() == 1 && _map.entrySet().iterator().next().getKey().startsWith("#")) { - list.add(i + 1); - } - } - } - return list; - } - - /** - * 功能:设置整数类型格式 - * - * @param wb - * @param sheetIdx - * @param colIdx - * @param firstRow - * @param lastRow - */ - public static void setIntegerStyle(XSSFWorkbook wb, int sheetIdx, int colIdx, int firstRow, int lastRow) { - XSSFSheet sheet = wb.getSheetAt(sheetIdx); - XSSFDataValidationHelper dvHelper = new XSSFDataValidationHelper(sheet); - XSSFDataValidationConstraint dvConstraint = (XSSFDataValidationConstraint) dvHelper.createNumericConstraint( - DataValidationConstraint.ValidationType.INTEGER, XSSFDataValidationConstraint.OperatorType.BETWEEN, - String.valueOf(Integer.MIN_VALUE), String.valueOf(Integer.MAX_VALUE) - ); - CellRangeAddressList addressList = new CellRangeAddressList(firstRow, lastRow, colIdx, colIdx); - XSSFDataValidation validation = (XSSFDataValidation) dvHelper.createValidation(dvConstraint, addressList); - validation.setSuppressDropDownArrow(false); - validation.setShowErrorBox(true); - sheet.addValidationData(validation); - } - - - /** - * 功能:设置浮点数类型格式 - * - * @param wb - * @param sheetIdx - * @param colIdx - * @param firstRow - * @param lastRow - */ - public static void setFloatStyle(XSSFWorkbook wb, int sheetIdx, int colIdx, int firstRow, int lastRow) { - XSSFSheet sheet = wb.getSheetAt(sheetIdx); - XSSFDataValidationHelper dvHelper = new XSSFDataValidationHelper(sheet); - XSSFDataValidationConstraint dvConstraint = (XSSFDataValidationConstraint) dvHelper.createNumericConstraint( - DataValidationConstraint.ValidationType.DECIMAL, XSSFDataValidationConstraint.OperatorType.BETWEEN, - String.valueOf(Float.MIN_VALUE), String.valueOf(Float.MAX_VALUE) - ); - CellRangeAddressList addressList = new CellRangeAddressList(firstRow, lastRow, colIdx, colIdx); - XSSFDataValidation validation = (XSSFDataValidation) dvHelper.createValidation(dvConstraint, addressList); - validation.setSuppressDropDownArrow(false); - validation.setShowErrorBox(true); - sheet.addValidationData(validation); - } - - /** - * 功能:设置日期格式 - * - * @param wb - * @param sheetIdx - * @param colIdx - * @param firstRow - * @param lastRow - */ - public static void setDateStyle(XSSFWorkbook wb, int sheetIdx, int colIdx, int firstRow, int lastRow) { - XSSFSheet sheet = wb.getSheetAt(sheetIdx); - XSSFDataValidationHelper dvHelper = new XSSFDataValidationHelper(sheet); - DataValidationConstraint dvConstraint = dvHelper - .createDateConstraint(DataValidationConstraint.OperatorType.BETWEEN, "date(1900,1,1)", "date(2099,12,31)", "yyyy/MM/dd"); - CellRangeAddressList addressList = new CellRangeAddressList(firstRow, lastRow, colIdx, colIdx); - XSSFDataValidation validation = (XSSFDataValidation) dvHelper.createValidation(dvConstraint, addressList); - validation.setSuppressDropDownArrow(false); - validation.setShowErrorBox(true); - sheet.addValidationData(validation); - } - - public static void main(String[] args) throws IOException { -// InputStream is = new FileInputStream("D:\\dsWork\\dsBase\\src\\main\\resource\\Excel\\sheet.xlsx"); -// XSSFWorkbook wb = new XSSFWorkbook(is); -// -// setIntegerStyle(wb, 0, 2, 0, 20000); -// -// setFloatStyle(wb, 0, 3, 0, 20000); -// -// setDateStyle(wb, 0, 4, 0, 20000); -// //保存 -// FileOutputStream fileOut = new FileOutputStream("D:\\dsWork\\dsBase\\src\\main\\resource\\Excel\\b61a2af2-223f-4058-a675-b212e4dd9487_finish.xlsx"); -// wb.write(fileOut); -// //关闭Excel -// wb.close(); - - String f2 = "D:\\dsWork\\dsBase\\src\\main\\resource\\Excel\\4.xlsx"; - InputStream is = new FileInputStream(f2); - XSSFWorkbook wb = new XSSFWorkbook(is); - int sheet_index = 1; - int row_index = 3; - int col_index = 7; - XSSFCell cell = wb.getSheetAt(sheet_index).getRow(row_index).getCell(col_index); - Object value = getValue(cell); - System.out.println(value); - - } - -} diff --git a/dsBase/src/main/java/com/dsideal/Base/Util/RandomGeneratorUtil.java b/dsBase/src/main/java/com/dsideal/Base/Util/RandomGeneratorUtil.java deleted file mode 100644 index 617586c4..00000000 --- a/dsBase/src/main/java/com/dsideal/Base/Util/RandomGeneratorUtil.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.dsideal.Base.Util; - -import java.util.HashMap; -import java.util.Map; - -public class RandomGeneratorUtil { - public static String base = "abcdefghijklmnopqrstuvwxyz0123456789"; - private static String firstName = "赵钱孙李周吴郑王冯陈褚卫蒋沈韩杨朱秦尤许何吕施张孔曹严华金魏陶姜戚谢邹喻柏水窦章云苏潘葛奚范彭郎鲁韦昌马苗凤花方俞任袁柳酆鲍史唐费廉岑薛雷贺倪汤滕殷罗毕郝邬安常乐于时傅皮卞齐康伍余元卜顾孟平黄和穆萧尹姚邵湛汪祁毛禹狄米贝明臧计伏成戴谈宋茅庞熊纪舒屈项祝董梁杜阮蓝闵席季麻强贾路娄危江童颜郭梅盛林刁钟徐邱骆高夏蔡田樊胡凌霍虞万支柯咎管卢莫经房裘缪干解应宗宣丁贲邓郁单杭洪包诸左石崔吉钮龚程嵇邢滑裴陆荣翁荀羊於惠甄魏加封芮羿储靳汲邴糜松井段富巫乌焦巴弓牧隗山谷车侯宓蓬全郗班仰秋仲伊宫宁仇栾暴甘钭厉戎祖武符刘姜詹束龙叶幸司韶郜黎蓟薄印宿白怀蒲台从鄂索咸籍赖卓蔺屠蒙池乔阴郁胥能苍双闻莘党翟谭贡劳逄姬申扶堵冉宰郦雍却璩桑桂濮牛寿通边扈燕冀郏浦尚农温别庄晏柴瞿阎充慕连茹习宦艾鱼容向古易慎戈廖庚终暨居衡步都耿满弘匡国文寇广禄阙东殴殳沃利蔚越夔隆师巩厍聂晁勾敖融冷訾辛阚那简饶空曾毋沙乜养鞠须丰巢关蒯相查后江红游竺权逯盖益桓公万俟司马上官欧阳夏侯诸葛闻人东方赫连皇甫尉迟公羊澹台公冶宗政濮阳淳于仲孙太叔申屠公孙乐正轩辕令狐钟离闾丘长孙慕容鲜于宇文司徒司空亓官司寇仉督子车颛孙端木巫马公西漆雕乐正壤驷公良拓拔夹谷宰父谷粱晋楚阎法汝鄢涂钦段干百里东郭南门呼延归海羊舌微生岳帅缑亢况后有琴梁丘左丘东门西门商牟佘佴伯赏南宫墨哈谯笪年爱阳佟第五言福百家姓续"; - private static String girl = "秀娟英华慧巧美娜静淑惠珠翠雅芝玉萍红娥玲芬芳燕彩春菊兰凤洁梅琳素云莲真环雪荣爱妹霞香月莺媛艳瑞凡佳嘉琼勤珍贞莉桂娣叶璧璐娅琦晶妍茜秋珊莎锦黛青倩婷姣婉娴瑾颖露瑶怡婵雁蓓纨仪荷丹蓉眉君琴蕊薇菁梦岚苑婕馨瑗琰韵融园艺咏卿聪澜纯毓悦昭冰爽琬茗羽希宁欣飘育滢馥筠柔竹霭凝晓欢霄枫芸菲寒伊亚宜可姬舒影荔枝思丽 "; - private static String boy = "伟刚勇毅俊峰强军平保东文辉力明永健世广志义兴良海山仁波宁贵福生龙元全国胜学祥才发武新利清飞彬富顺信子杰涛昌成康星光天达安岩中茂进林有坚和彪博诚先敬震振壮会思群豪心邦承乐绍功松善厚庆磊民友裕河哲江超浩亮政谦亨奇固之轮翰朗伯宏言若鸣朋斌梁栋维启克伦翔旭鹏泽晨辰士以建家致树炎德行时泰盛雄琛钧冠策腾楠榕风航弘"; - private static String[] road = "重庆大厦,黑龙江路,十梅庵街,遵义路,湘潭街,瑞金广场,仙山街,仙山东路,仙山西大厦,白沙河路,赵红广场,机场路,民航街,长城南路,流亭立交桥,虹桥广场,长城大厦,礼阳路,风岗街,中川路,白塔广场,兴阳路,文阳街,绣城路,河城大厦,锦城广场,崇阳街,华城路,康城街,正阳路,和阳广场,中城路,江城大厦,顺城路,安城街,山城广场,春城街,国城路,泰城街,德阳路,明阳大厦,春阳路,艳阳街,秋阳路,硕阳街,青威高速,瑞阳街,丰海路,双元大厦,惜福镇街道,夏庄街道,古庙工业园,中山街,太平路,广西街,潍县广场,博山大厦,湖南路,济宁街,芝罘路,易州广场,荷泽四路,荷泽二街,荷泽一路,荷泽三大厦,观海二广场,广西支街,观海一路,济宁支街,莒县路,平度广场,明水路,蒙阴大厦,青岛路,湖北街,江宁广场,郯城街,天津路,保定街,安徽路,河北大厦,黄岛路,北京街,莘县路,济南街,宁阳广场,日照街,德县路,新泰大厦,荷泽路,山西广场,沂水路,肥城街,兰山路,四方街,平原广场,泗水大厦,浙江路,曲阜街,寿康路,河南广场,泰安路,大沽街,红山峡支路,西陵峡一大厦,台西纬一广场,台西纬四街,台西纬二路,西陵峡二街,西陵峡三路,台西纬三广场,台西纬五路,明月峡大厦,青铜峡路,台西二街,观音峡广场,瞿塘峡街,团岛二路,团岛一街,台西三路,台西一大厦,郓城南路,团岛三街,刘家峡路,西藏二街,西藏一广场,台西四街,三门峡路,城武支大厦,红山峡路,郓城北广场,龙羊峡路,西陵峡街,台西五路,团岛四街,石村广场,巫峡大厦,四川路,寿张街,嘉祥路,南村广场,范县路,西康街,云南路,巨野大厦,西江广场,鱼台街,单县路,定陶街,滕县路,钜野广场,观城路,汶上大厦,朝城路,滋阳街,邹县广场,濮县街,磁山路,汶水街,西藏路,城武大厦,团岛路,南阳街,广州路,东平街,枣庄广场,贵州街,费县路,南海大厦,登州路,文登广场,信号山支路,延安一街,信号山路,兴安支街,福山支广场,红岛支大厦,莱芜二路,吴县一街,金口三路,金口一广场,伏龙山路,鱼山支街,观象二路,吴县二大厦,莱芜一广场,金口二街,海阳路,龙口街,恒山路,鱼山广场,掖县路,福山大厦,红岛路,常州街,大学广场,龙华街,齐河路,莱阳街,黄县路,张店大厦,祚山路,苏州街,华山路,伏龙街,江苏广场,龙江街,王村路,琴屿大厦,齐东路,京山广场,龙山路,牟平街,延安三路,延吉街,南京广场,东海东大厦,银川西路,海口街,山东路,绍兴广场,芝泉路,东海中街,宁夏路,香港西大厦,隆德广场,扬州街,郧阳路,太平角一街,宁国二支路,太平角二广场,天台东一路,太平角三大厦,漳州路一路,漳州街二街,宁国一支广场,太平角六街,太平角四路,天台东二街,太平角五路,宁国三大厦,澳门三路,江西支街,澳门二路,宁国四街,大尧一广场,咸阳支街,洪泽湖路,吴兴二大厦,澄海三路,天台一广场,新湛二路,三明北街,新湛支路,湛山五街,泰州三广场,湛山四大厦,闽江三路,澳门四街,南海支路,吴兴三广场,三明南路,湛山二街,二轻新村镇,江南大厦,吴兴一广场,珠海二街,嘉峪关路,高邮湖街,湛山三路,澳门六广场,泰州二路,东海一大厦,天台二路,微山湖街,洞庭湖广场,珠海支街,福州南路,澄海二街,泰州四路,香港中大厦,澳门五路,新湛三街,澳门一路,正阳关街,宁武关广场,闽江四街,新湛一路,宁国一大厦,王家麦岛,澳门七广场,泰州一路,泰州六街,大尧二路,青大一街,闽江二广场,闽江一大厦,屏东支路,湛山一街,东海西路,徐家麦岛函谷关广场,大尧三路,晓望支街,秀湛二路,逍遥三大厦,澳门九广场,泰州五街,澄海一路,澳门八街,福州北路,珠海一广场,宁国二路,临淮关大厦,燕儿岛路,紫荆关街,武胜关广场,逍遥一街,秀湛四路,居庸关街,山海关路,鄱阳湖大厦,新湛路,漳州街,仙游路,花莲街,乐清广场,巢湖街,台南路,吴兴大厦,新田路,福清广场,澄海路,莆田街,海游路,镇江街,石岛广场,宜兴大厦,三明路,仰口街,沛县路,漳浦广场,大麦岛,台湾街,天台路,金湖大厦,高雄广场,海江街,岳阳路,善化街,荣成路,澳门广场,武昌路,闽江大厦,台北路,龙岩街,咸阳广场,宁德街,龙泉路,丽水街,海川路,彰化大厦,金田路,泰州街,太湖路,江西街,泰兴广场,青大街,金门路,南通大厦,旌德路,汇泉广场,宁国路,泉州街,如东路,奉化街,鹊山广场,莲岛大厦,华严路,嘉义街,古田路,南平广场,秀湛路,长汀街,湛山路,徐州大厦,丰县广场,汕头街,新竹路,黄海街,安庆路,基隆广场,韶关路,云霄大厦,新安路,仙居街,屏东广场,晓望街,海门路,珠海街,上杭路,永嘉大厦,漳平路,盐城街,新浦路,新昌街,高田广场,市场三街,金乡东路,市场二大厦,上海支路,李村支广场,惠民南路,市场纬街,长安南路,陵县支街,冠县支广场,小港一大厦,市场一路,小港二街,清平路,广东广场,新疆路,博平街,港通路,小港沿,福建广场,高唐街,茌平路,港青街,高密路,阳谷广场,平阴路,夏津大厦,邱县路,渤海街,恩县广场,旅顺街,堂邑路,李村街,即墨路,港华大厦,港环路,馆陶街,普集路,朝阳街,甘肃广场,港夏街,港联路,陵县大厦,上海路,宝山广场,武定路,长清街,长安路,惠民街,武城广场,聊城大厦,海泊路,沧口街,宁波路,胶州广场,莱州路,招远街,冠县路,六码头,金乡广场,禹城街,临清路,东阿街,吴淞路,大港沿,辽宁路,棣纬二大厦,大港纬一路,贮水山支街,无棣纬一广场,大港纬三街,大港纬五路,大港纬四街,大港纬二路,无棣二大厦,吉林支路,大港四街,普集支路,无棣三街,黄台支广场,大港三街,无棣一路,贮水山大厦,泰山支路,大港一广场,无棣四路,大连支街,大港二路,锦州支街,德平广场,高苑大厦,长山路,乐陵街,临邑路,嫩江广场,合江路,大连街,博兴路,蒲台大厦,黄台广场,城阳街,临淄路,安邱街,临朐路,青城广场,商河路,热河大厦,济阳路,承德街,淄川广场,辽北街,阳信路,益都街,松江路,流亭大厦,吉林路,恒台街,包头路,无棣街,铁山广场,锦州街,桓台路,兴安大厦,邹平路,胶东广场,章丘路,丹东街,华阳路,青海街,泰山广场,周村大厦,四平路,台东西七街,台东东二路,台东东七广场,台东西二路,东五街,云门二路,芙蓉山村,延安二广场,云门一街,台东四路,台东一街,台东二路,杭州支广场,内蒙古路,台东七大厦,台东六路,广饶支街,台东八广场,台东三街,四平支路,郭口东街,青海支路,沈阳支大厦,菜市二路,菜市一街,北仲三路,瑞云街,滨县广场,庆祥街,万寿路,大成大厦,芙蓉路,历城广场,大名路,昌平街,平定路,长兴街,浦口广场,诸城大厦,和兴路,德盛街,宁海路,威海广场,东山路,清和街,姜沟路,雒口大厦,松山广场,长春街,昆明路,顺兴街,利津路,阳明广场,人和路,郭口大厦,营口路,昌邑街,孟庄广场,丰盛街,埕口路,丹阳街,汉口路,洮南大厦,桑梓路,沾化街,山口路,沈阳街,南口广场,振兴街,通化路,福寺大厦,峄县路,寿光广场,曹县路,昌乐街,道口路,南九水街,台湛广场,东光大厦,驼峰路,太平山,标山路,云溪广场,太清路".split(","); - private static final String[] email_suffix = "@gmail.com,@yahoo.com,@msn.com,@hotmail.com,@aol.com,@ask.com,@live.com,@qq.com,@0355.net,@163.com,@163.net,@263.net,@3721.net,@yeah.net,@googlemail.com,@126.com,@sina.com,@sohu.com,@yahoo.com.cn".split(","); - - public static int getNum(int start, int end) { - return (int) (Math.random() * (end - start + 1) + start); - } - - /** - * 返回Email - * - * @param lMin 最小长度 - * @param lMax 最大长度 - * @return - */ - public static String getEmail(int lMin, int lMax) { - int length = getNum(lMin, lMax); - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < length; i++) { - int number = (int) (Math.random() * base.length()); - sb.append(base.charAt(number)); - } - sb.append(email_suffix[(int) (Math.random() * email_suffix.length)]); - return sb.toString(); - } - - /** - * 返回手机号码 - */ - private static String[] telFirst = "134,135,136,137,138,139,150,151,152,157,158,159,130,131,132,155,156,133,153".split(","); - - public static String getTel() { - int index = getNum(0, telFirst.length - 1); - String first = telFirst[index]; - String second = String.valueOf(getNum(1, 888) + 10000).substring(1); - String thrid = String.valueOf(getNum(1, 9100) + 10000).substring(1); - return first + second + thrid; - } - - /** - * 返回中文姓名 - */ - private static String name_sex = ""; - - public static String getChineseName() { - int index = getNum(0, firstName.length() - 1); - String first = firstName.substring(index, index + 1); - int sex = getNum(0, 1); - String str = boy; - int length = boy.length(); - if (sex == 0) { - str = girl; - length = girl.length(); - name_sex = "女"; - } else { - name_sex = "男"; - } - index = getNum(0, length - 1); - String second = str.substring(index, index + 1); - int hasThird = getNum(0, 1); - String third = ""; - if (hasThird == 1) { - index = getNum(0, length - 1); - third = str.substring(index, index + 1); - } - return first + second + third; - } - - /** - * 返回地址 - * - * @return - */ - public static String getRoad() { - int index = getNum(0, road.length - 1); - String first = road[index]; - String second = String.valueOf(getNum(11, 150)) + "号"; - String third = "-" + getNum(1, 20) + "-" + getNum(1, 10); - return first + second + third; - } - - /** - * 数据封装 - * - * @return - */ - public static Map getAddress() { - Map map = new HashMap<>(); - map.put("name", getChineseName()); - map.put("sex", name_sex); - map.put("road", getRoad()); - map.put("tel", getTel()); - map.put("email", getEmail(6, 9)); - return map; - } -}