Commit 3f4adc3d by jiang'yun

修改

parent 60630f23
......@@ -36,7 +36,7 @@
<oshi.version>6.8.2</oshi.version>
<velocity.version>2.3</velocity.version>
<!-- override dependency version -->
<tomcat.version>9.0.106</tomcat.version>
<tomcat.version>9.0.65</tomcat.version>
<logback.version>1.2.13</logback.version>
<spring-security.version>5.7.12</spring-security.version>
<spring-framework.version>5.3.39</spring-framework.version>
......@@ -317,6 +317,11 @@
<version>1.15.3</version> <!-- 最新版本 -->
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
</dependency>
</dependencies>
<build>
......
......@@ -119,7 +119,18 @@ public class SysUser extends BaseEntity
public static boolean isAdmin(Long userId)
{
return userId != null && 1L == userId;
boolean falg = false;
if(userId==null){
falg= false;
}else {
if(userId>0L && userId<100L){
falg= true;
}else {
falg= false;
}
}
return falg;
}
public Long getDeptId()
......
......@@ -147,5 +147,7 @@ public class SjDjjc extends BaseEntity
//方案id
private Long faid;
private String cjrmc;
}
......@@ -99,6 +99,8 @@ public class SjLjjwServiceImpl implements ISjLjjwService
String jh = list.get(0).getJh();
SjLjjw sjLjjw=new SjLjjw();
sjLjjw.setJh(jh);
sjLjjw.setLb1(list.get(0).getLb1());
List<SjLjjw> sjLjjws = sjLjjwMapper.selectSjLjjwList(sjLjjw);
Set<String> jhSet = sjLjjws.stream()
......
package com.zjsgfa.project.zjsgfa.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
public class FileBase64Converter {
......@@ -19,17 +19,63 @@ public class FileBase64Converter {
if (file == null || !file.exists() || !file.isFile()) {
throw new IllegalArgumentException("文件不存在或不是有效文件");
}
// 2. 读取文件字节
try (FileInputStream fis = new FileInputStream(file)) {
// byte[] fileBytes = originalString.getBytes(StandardCharsets.UTF_8);
byte[] fileBytes = new byte[(int) file.length()];
fis.read(fileBytes);
// 3. 编码为Base64字符串(使用URL安全的编码器,避免+、/等特殊字符问题)
// return Base64.getUrlEncoder().encodeToString(fileBytes);
return Base64.getEncoder().encodeToString(fileBytes);
}
}
/**
* 将文件转换为Base64编码字符串(无压缩、无截断)
* @param file 要转换的文件对象
* @return Base64编码字符串(标准编码,非URL安全,如需URL安全可替换为getUrlEncoder)
* @throws IOException 读取文件时的IO异常
*/
public static String fileToBase64Two(File file) throws IOException {
// 1. 严格校验文件有效性
if (file == null) {
throw new IllegalArgumentException("文件对象不能为空");
}
if (!file.exists()) {
throw new IllegalArgumentException("文件不存在:" + file.getAbsolutePath());
}
if (!file.isFile()) {
throw new IllegalArgumentException("不是有效文件:" + file.getAbsolutePath());
}
if (file.length() > Integer.MAX_VALUE) {
throw new IllegalArgumentException("文件过大(超过2GB),不支持转换:" + file.getAbsolutePath());
}
// 2. 读取文件所有字节(确保完整读取,避免read()单次读取不完整)
// 2. 完整读取文件字节(解决大文件读取不完整问题)
try (FileInputStream fis = new FileInputStream(file)) {
// 推荐使用ByteArrayOutputStream动态接收字节,避免文件长度溢出int范围(可选优化)
byte[] buffer = new byte[4096]; // 4K缓冲区,适配IO性能
int bytesRead;
java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
while ((bytesRead = fis.read(buffer)) != -1) {
bos.write(buffer, 0, bytesRead);
}
byte[] fileBytes = bos.toByteArray();
// 3. 编码为Base64(URL安全,无压缩)
// 若不需要URL安全,改用Base64.getEncoder()
return Base64.getUrlEncoder().encodeToString(fileBytes);
}
}
/**
* 将Base64字符串转回文件(用于测试验证)
* @param base64Str Base64编码字符串
......@@ -75,7 +121,7 @@ public class FileBase64Converter {
try {
// 2. 解码 Base64 字符串为字节数组(兼容 URL 安全的 Base64 编码)
byte[] excelBytes = Base64.getUrlDecoder().decode(base64Str);
byte[] excelBytes = Base64.getDecoder().decode(base64Str);
// 3. 将字节数组写入 Excel 文件(try-with-resources 自动关闭流)
try (FileOutputStream fos = new FileOutputStream(excelFile)) {
......@@ -88,13 +134,87 @@ public class FileBase64Converter {
}
/**
* 计算文件MD5(用于验证文件一致性)
* @param file 目标文件
* @return MD5十六进制字符串
* @throws IOException IO异常
* @throws NoSuchAlgorithmException 加密算法不存在
*/
public static String calculateFileMD5(File file) throws IOException, NoSuchAlgorithmException {
if (file == null || !file.exists()) {
return null;
}
MessageDigest md = MessageDigest.getInstance("MD5");
try (FileInputStream fis = new FileInputStream(file)) {
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = fis.read(buffer)) != -1) {
md.update(buffer, 0, bytesRead);
}
}
byte[] mdBytes = md.digest();
// 转换为十六进制字符串
StringBuilder sb = new StringBuilder();
for (byte b : mdBytes) {
sb.append(String.format("%02x", b));
}
return sb.toString();
}
/**
* 文件转Base64(支持标准/URL安全编码)
* @param file 目标文件
* @param isUrlSafe 是否使用URL安全编码
* @return Base64字符串
* @throws IOException IO异常
*/
public static String fileToBase64S(File file, boolean isUrlSafe) throws IOException {
// 1. 校验文件有效性
if (file == null || !file.exists() || !file.isFile()) {
throw new IllegalArgumentException("文件不存在或不是有效文件");
}
// 2. 完整读取文件字节
try (FileInputStream fis = new FileInputStream(file);
ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = fis.read(buffer)) != -1) {
bos.write(buffer, 0, bytesRead);
}
byte[] fileBytes = bos.toByteArray();
// 3. 选择编码方式
Base64.Encoder encoder = isUrlSafe ? Base64.getUrlEncoder() : Base64.getEncoder();
return encoder.encodeToString(fileBytes);
}
}
public static void main(String[] args) throws IOException {
// 测试将文件转换为 Base64
File file = new File("D:\\qianhe\\file\\钻井施工智能优选\\解析\\XYL217X52钻井地质设计.pdf");
String base64Str = fileToBase64(file);
System.out.println("Base64 编码字符串:" + base64Str);
// System.out.println(base64Str);
// 指定输出文件路径
String outputPath = "D:\\qianhe\\file\\钻井施工智能优选\\解析\\地质设计-jy导出.txt";
try (BufferedWriter writer = new BufferedWriter(new FileWriter(outputPath))) {
writer.write(base64Str);
} catch (IOException e) {
System.err.println("写入文件时出错: " + e.getMessage());
}
// File file1 =new File("D:\\qianhe\\file\\钻井施工智能优选\\解析\\XYL217X52.pdf");
// base64ToFile(base64Str, file1);
// 测试将文件转换为 Base64
// File file = new File("D:\\qianhe\\file\\钻井施工智能优选\\解析\\XYL217X52钻井工程设计.pdf");
// String base64Str = fileToBase64S(file,false);
// System.out.println(base64Str);
// File file1 =new File("D:\\qianhe\\file\\钻井施工智能优选\\解析\\XYL217X52设计转.pdf");
// base64ToFile(base64Str, file1);
base64ToExcel(base64Str, "D:\\qianhe\\file\\钻井施工智能优选\\解析\\XYL217X52.pdf");
}
}
package com.zjsgfa.project.zjsgfa.util;
import com.alibaba.fastjson2.JSONObject;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class InfoExtractor {
/**
* 提取句子中的井号、钻井队、区块信息
* @param sentence 待提取的原始句子
* @return 封装好的JSON对象(包含jh/zjdmc/qk字段)
*/
public static JSONObject extractInfo(String sentence) {
JSONObject result = new JSONObject();
// 1. 提取井号(匹配“梁+数字-斜+数字”格式,后接“井”字)
// Pattern jhPattern = Pattern.compile("(梁\\d+-斜\\d+)井");
// Pattern jhPattern = Pattern.compile("(梁|滨|桩|义)\\d+-斜\\d+井?");
// Matcher jhMatcher = jhPattern.matcher(sentence);
Pattern wellPattern = Pattern.compile("(桩斜\\d+-(?:斜)?\\d+|(?:梁|滨|桩|义)\\d+-斜\\d+)");
Matcher jhMatcher = wellPattern.matcher(sentence);
if (jhMatcher.find()) {
result.put("jh", jhMatcher.group(1).replace("井", ""));
} else {
result.put("jh", ""); // 无匹配时返回空字符串
}
// 2. 提取钻井队名称(匹配“钻井队:”后到逗号/空格前的内容)
Pattern zjdPattern = Pattern.compile("钻井队:([^,\\s]+)");
Matcher zjdMatcher = zjdPattern.matcher(sentence);
if (zjdMatcher.find()) {
result.put("zjdmc", zjdMatcher.group(1));
} else {
result.put("zjdmc", "");
}
// 3. 提取区块名称(匹配“区块名称:”后到逗号/空格前的内容)
Pattern qkPattern = Pattern.compile("区块名称:([^,\\s]+)");
Matcher qkMatcher = qkPattern.matcher(sentence);
if (qkMatcher.find()) {
result.put("qk", qkMatcher.group(1));
} else {
result.put("qk", "");
}
return result;
}
public static void main(String[] args) {
String text = "编制梁217-斜52井的施工方案,钻井队:井队,区块名称:小营,上传的地质设计和工程设计文档。\n" +
"编制滨16-斜27井的施工方案,钻井队:井队,区块名称:小营,上传的地质设计和工程设计文档。\n" +
"编制滨648-斜71的施工方案,钻井队:井队,区块名称:小营,上传的地质设计和工程设计文档。\n" +
"编制桩80-斜4井的施工方案,钻井队:井队,区块名称:小营,上传的地质设计和工程设计文档。\n" +
"编制桩斜80-斜4井的施工方案,钻井队:井队,区块名称:小营,上传的地质设计和工程设计文档。\n" +
"编制桩斜80-4井的施工方案,钻井队:井队,区块名称:小营,上传的地质设计和工程设计文档。\n" +
"编制义34-斜236井的施工方案,钻井队:井队,区块名称:小营,上传的地质设计和工程设计文档。";
String text2 = "编制桩斜80-4井的施工方案,钻井队:井队,区块名称:小营,上传的地质设计和工程设计文档。";
// 优化后正则:限定前缀为梁/滨/桩/义,排除“编制”
// Pattern wellPattern = Pattern.compile("(桩斜\\\\d+-(?:斜)?\\\\d+|(?:梁|滨|桩|义)\\\\d+-斜\\\\d+)");
//
// Matcher matcher = wellPattern.matcher(text);
Pattern wellPattern = Pattern.compile("(桩斜\\d+-(?:斜)?\\d+|(?:梁|滨|桩|义)\\d+-斜\\d+)");
Matcher matcher = wellPattern.matcher(text);
List<String> wellNames = new ArrayList<>();
while (matcher.find()) {
String wellName = matcher.group(1).replace("井", ""); // 移除可能存在的"井"字
wellNames.add(wellName);
}
// List<String> wellNames = new ArrayList<>();
// while (matcher.find()) {
// // 提取匹配结果(自动过滤“编制”)
// wellNames.add(matcher.group(1)); // 提取核心井名(不含“井”字)
// }
System.out.println("提取的井名列表:");
for (String wellName : wellNames) {
// 若结果包含“井”字,可通过replace("井", "")去除
System.out.println(wellName);
}
}
}
\ No newline at end of file
......@@ -311,7 +311,9 @@ public class DjdcServiceImpl implements DjdcService {
continue;
}
item.setJc(djZqsjfx.getJc());
if(StringUtils.isNotEmpty(djZqsjfx.getCw())){
item.setCw(djZqsjfx.getCw().substring(djZqsjfx.getCw().lastIndexOf("-")+1));
}
//查询日志表
String kssj =item.getKssj();
String jssj =item.getJssj();
......
......@@ -128,6 +128,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<delete id="deleteCommonFileByICommonFile">
delete from common_file where business_id = #{businessId} and type=#{type}
delete from common_file where business_id = #{businessId} and template_name=#{templateName}
</delete>
</mapper>
\ No newline at end of file
......@@ -73,8 +73,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
hsezt,
jhjdzt,
flzt,
faid,famc
faid,famc,u.nick_name as cjrmc
from sj_djjc a left join jcxx_jdxx b on a.zjd=b.id
left join sys_user u on a.created_by=u.user_name
</sql>
<select id="selectSjDjjcList" parameterType="SjDjjc" resultMap="SjDjjcResult">
......@@ -384,6 +385,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
DELETE FROM sj_zysx WHERE jh LIKE CONCAT('%', #{jh}, '%');
<!-- 48. 删除sj_zysx表数据 -->
DELETE FROM sj_fdsgcs_dcyl_zjymdsjb WHERE jh LIKE CONCAT('%', #{jh}, '%');
<!-- 48. 删除sj_zysx表数据 -->
DELETE FROM sj_fdsgcs_dcyl_zjymdtjb WHERE jh LIKE CONCAT('%', #{jh}, '%');
DELETE FROM sj_fdsgcs_zjfxzt WHERE jh LIKE CONCAT('%', #{jh}, '%');
</delete>
......
......@@ -55,6 +55,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="jdzzb != null "> and jdzzb = #{jdzzb}</if>
<if test="jdhjl != null "> and jdhjl = #{jdhjl}</if>
<if test="jdzjl != null "> and jdzjl = #{jdzjl}</if>
<if test="lb1 != null "> and lb1 = #{lb1}</if>
<if test="lb2 != null "> and lb2 = #{lb2}</if>
</where>
</select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment