Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zjsgfa_mysql
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jiangyun
zjsgfa_mysql
Commits
4a6cf2a2
Commit
4a6cf2a2
authored
Dec 10, 2025
by
jiang'yun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
parent
1ada7cfc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
20 deletions
+55
-20
src/main/java/com/zjsgfa/project/zjsgfa/controller/SjDjjcController.java
+2
-0
src/main/java/com/zjsgfa/project/zjsgfa/service/impl/SjFdsgcsServiceImpl.java
+50
-20
src/main/java/com/zjsgfa/project/zt/service/impl/DjdcServiceImpl.java
+3
-0
No files found.
src/main/java/com/zjsgfa/project/zjsgfa/controller/SjDjjcController.java
View file @
4a6cf2a2
...
...
@@ -523,6 +523,8 @@ public class SjDjjcController extends BaseController
String
sjdcs
=
new
DataFormatter
().
formatCellValue
(
row
.
getCell
(
5
));
if
(
StringUtils
.
isNotEmpty
(
sjdcs
)){
sjDzfc
.
setSjdcs
(
Double
.
parseDouble
(
sjdcs
));
}
else
{
continue
;
}
...
...
src/main/java/com/zjsgfa/project/zjsgfa/service/impl/SjFdsgcsServiceImpl.java
View file @
4a6cf2a2
...
...
@@ -8,10 +8,7 @@ import java.util.stream.Collectors;
import
cn.hutool.core.codec.Base64
;
import
cn.hutool.http.HttpRequest
;
import
com.google.gson.Gson
;
import
com.google.gson.GsonBuilder
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
com.google.gson.*
;
import
com.zjsgfa.common.utils.DateUtils
;
import
com.zjsgfa.common.utils.StringUtils
;
import
com.zjsgfa.framework.util.HttpsPostUtil
;
...
...
@@ -333,27 +330,30 @@ public class SjFdsgcsServiceImpl implements ISjFdsgcsService
String
url
=
"https://10.68.249.59:12001/api/ljzjymd"
;
System
.
out
.
println
(
json
);
String
result
=
HttpRequest
.
post
(
url
).
body
(
json
).
execute
().
body
();
// String result = HttpsSkipVerifyUtil.doPost(url, json);
System
.
out
.
println
(
result
);
JsonObject
root
=
gson
.
fromJson
(
result
,
JsonObject
.
class
);
JsonObject
outerData
=
root
.
getAsJsonObject
(
"data"
);
List
<
String
>
dcylmsList
=
new
ArrayList
<>();
for
(
String
ljh:
jh_list
){
JsonObject
innerData
=
outerData
.
getAsJsonObject
(
ljh
);
if
(
innerData
!=
null
){
//邻井钻井液密度数据表
JsonArray
zjymdsjb
=
innerData
.
getAsJsonArray
(
"邻井钻井液密度数据表"
);
List
<
SjFdsgcsDcylZjymdsjb
>
list
=
getZjymdsjbList
(
zjymdsjb
,
sjFdsgcs
.
getJh
(),
sjFdsgcsDcyxes
);
zjymdsjbList
.
addAll
(
list
);
//邻井钻井液密度统计表
JsonArray
zjymdtjb
=
innerData
.
getAsJsonArray
(
"邻井钻井液密度统计表"
);
zjymdtjbList
.
addAll
(
getZjymdtjbList
(
zjymdtjb
,
ljh
,
sjFdsgcs
.
getJh
(),
sjFdsgcsDcyxes
));
//地层压力描述文本
JsonObject
jsonObject
=
safeParseJsonObject
(
result
);
if
(
jsonObject
!=
null
){
JsonObject
root
=
gson
.
fromJson
(
result
,
JsonObject
.
class
);
JsonObject
outerData
=
root
.
getAsJsonObject
(
"data"
);
List
<
String
>
dcylmsList
=
new
ArrayList
<>();
for
(
String
ljh:
jh_list
){
JsonObject
innerData
=
outerData
.
getAsJsonObject
(
ljh
);
if
(
innerData
!=
null
){
//邻井钻井液密度数据表
JsonArray
zjymdsjb
=
innerData
.
getAsJsonArray
(
"邻井钻井液密度数据表"
);
List
<
SjFdsgcsDcylZjymdsjb
>
list
=
getZjymdsjbList
(
zjymdsjb
,
sjFdsgcs
.
getJh
(),
sjFdsgcsDcyxes
);
zjymdsjbList
.
addAll
(
list
);
//邻井钻井液密度统计表
JsonArray
zjymdtjb
=
innerData
.
getAsJsonArray
(
"邻井钻井液密度统计表"
);
zjymdtjbList
.
addAll
(
getZjymdtjbList
(
zjymdtjb
,
ljh
,
sjFdsgcs
.
getJh
(),
sjFdsgcsDcyxes
));
//地层压力描述文本
// String dcylms = innerData.get("地层压力描述文本").toString();
// dcylmsList.add("邻井"+ljh+dcylms);
}
}
}
//
//
////
...
...
@@ -1009,4 +1009,34 @@ public class SjFdsgcsServiceImpl implements ISjFdsgcsService
stat
.
setQycsMax
(
qycsMax
);
// 取样垂深最大值
list
.
add
(
stat
);
}
/**
* 安全解析 JSON 字符串为 JsonObject,避免解析异常
* @param jsonStr 待解析的字符串
* @return 解析后的 JsonObject(非 JSON 对象返回 null)
*/
public
static
JsonObject
safeParseJsonObject
(
String
jsonStr
)
{
Gson
gson
=
new
GsonBuilder
().
setPrettyPrinting
().
create
();
// 第一步:空值校验
if
(
jsonStr
==
null
||
jsonStr
.
trim
().
isEmpty
())
{
return
null
;
}
String
trimmedStr
=
jsonStr
.
trim
();
// 第二步:格式初步校验(JSON 对象必须以 { 开头,} 结尾)
if
(!
trimmedStr
.
startsWith
(
"{"
)
||
!
trimmedStr
.
endsWith
(
"}"
))
{
return
null
;
}
// 第三步:尝试解析,捕获解析异常
try
{
return
gson
.
fromJson
(
trimmedStr
,
JsonObject
.
class
);
}
catch
(
JsonParseException
e
)
{
// 解析失败(比如格式不合法的 JSON),返回 null
System
.
out
.
println
(
"JSON 解析失败:"
+
e
.
getMessage
());
return
null
;
}
}
}
src/main/java/com/zjsgfa/project/zt/service/impl/DjdcServiceImpl.java
View file @
4a6cf2a2
...
...
@@ -1726,6 +1726,9 @@ public class DjdcServiceImpl implements DjdcService {
sjDcfxTsyx
.
setJh
(
param
.
getJh
());
sjDcfxTsyx
.
setCw
(
ljDcyx
.
getDcmc
());
sjDcfxTsyx
.
setTsyx
(
ljDcyx
.
getYxmc
());
System
.
out
.
println
(
item
);
System
.
out
.
println
(
ljDcyx
);
System
.
out
.
println
(
bb
);
Double
cc
=
item
.
getSjdcs
()+(
item
.
getSjhd
()*
bb
);
sjDcfxTsyx
.
setJds
(
Double
.
parseDouble
(
String
.
format
(
"%.2f"
,
cc
)));
sjDcfxTsyx
.
setWt
(
ljDcyx
.
getWt
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment