main
HuangHai 1 month ago
parent 8e55d9481f
commit f88542ac39

@ -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

@ -1 +0,0 @@
https://help.aliyun.com/zh/model-studio/emo-api?spm=a2c4g.11186623.help-menu-2400256.d_2_3_4_1.7d8a5f84mfOU9j

@ -1 +0,0 @@
https://www.volcengine.com/docs/82379/1520757

@ -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
获取验证码登录

@ -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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 891 KiB

@ -1,3 +0,0 @@
https://goapi.gptnb.ai/account/profile
littlehb
mdcija780522

Binary file not shown.

Before

Width:  |  Height:  |  Size: 373 KiB

@ -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);

@ -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 {
}
}
/**
* ID1234-1
*
* @return
*/
public int getOrgLevel(String org_id) {
String sql = Db.getSql("dm.getOrgLevel");
List<Record> 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<Record> getAllAreaInfoByInstallCity() {
String sql = Db.getSql("dm.getAllAreaInfoByInstallCity");
return Db.find(sql);
}
}

@ -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<String, JedisCluster> 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 JedisClusternull
* @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;
}
/**
*
* mainCacheCachemainCache
*
* @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 JedisClusternull
* @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 truefalse
*/
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");
}
}

@ -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;
/**
* JFinalRedis
* <p>
*
* <ul>
* <li>JFinal 2.1+</li>
* <li>Jedis 2.7.2+</li>
* <li>commons-pool2 2.3+</li>
* </ul>
* <p>
*
* <ul>
* <li>jedis-2.7.2.jar</li>
* <li>commons-pool2-2.3.jar</li>
* </ul>
*
* @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<redis.clients.jedis.Connection> poolConfig;
/**
*
*/
private final Integer maxRedirections;
/**
*
*/
private final Set<HostAndPort> redisClusterNodes;
/**
*
*
* @param clusterName
* @param redisClusterNodes
* @throws IllegalArgumentException
*/
public RedisClusterPlugin(String clusterName, Set<HostAndPort> redisClusterNodes) {
this(clusterName, redisClusterNodes, null, null, null);
}
/**
*
*
* @param clusterName
* @param redisClusterNodes
* @param timeout null使
* @throws IllegalArgumentException
*/
public RedisClusterPlugin(String clusterName, Set<HostAndPort> redisClusterNodes, Integer timeout) {
this(clusterName, redisClusterNodes, timeout, null, null);
}
/**
*
*
* @param clusterName
* @param redisClusterNodes
* @param poolConfig null使
* @throws IllegalArgumentException
*/
public RedisClusterPlugin(String clusterName, Set<HostAndPort> redisClusterNodes, GenericObjectPoolConfig<redis.clients.jedis.Connection> poolConfig) {
this(clusterName, redisClusterNodes, null, null, poolConfig);
}
/**
*
*
* @param clusterName
* @param redisClusterNodes
* @param timeout null使
* @param poolConfig null使
* @throws IllegalArgumentException
*/
public RedisClusterPlugin(String clusterName, Set<HostAndPort> redisClusterNodes, Integer timeout, GenericObjectPoolConfig<redis.clients.jedis.Connection> poolConfig) {
this(clusterName, redisClusterNodes, timeout, null, poolConfig);
}
/**
*
*
* @param clusterName
* @param redisClusterNodes
* @param timeout null使
* @param maxRedirections null使
* @throws IllegalArgumentException
*/
public RedisClusterPlugin(String clusterName, Set<HostAndPort> 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<HostAndPort> redisClusterNodes, Integer timeout, Integer maxRedirections, GenericObjectPoolConfig<redis.clients.jedis.Connection> 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
* JedisClusterRedisCluster
*
* @return truefalse
*/
@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 truefalse
*/
@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<HostAndPort> 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 JedisClusternull
*/
public JedisCluster getJedisCluster() {
return jedisCluster;
}
/**
*
*
* @return truefalse
*/
public boolean isStarted() {
return jedisCluster != null;
}
}

@ -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;

@ -25,7 +25,6 @@ import java.util.*;
public class ExcelCommonUtil {
/**
* https://fireinwind.iteye.com/blog/2168655
* excel
*
* 2018-12-12

@ -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<Record> 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<Integer, String> _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();
}
}
}

@ -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;
}
}

@ -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);
}
}

@ -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<Record> 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<Record> 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<Record> 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";
}

@ -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);
}
/**
* EXCELString[]
*
* @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<Integer> getHead(XSSFSheet sheet) {
List<Integer> list = new ArrayList<>();
//整行都是同一种非空白颜色,视为表头
// 遍历行
for (int i = 0; i <= sheet.getLastRowNum(); i++) {
//获得行
XSSFRow row = sheet.getRow(i);
//遍历列
if (row != null) {
Map<String, Integer> _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);
}
}

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save