From 7dd91c931082963b580c6ea2668cbf4fc8031e74 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=90=91=E9=87=91=E6=88=90?= <2693239786@qq.com>
Date: Wed, 27 Sep 2023 09:33:49 +0800
Subject: [PATCH] update
---
src/medicine/.idea/compiler.xml | 1 -
src/medicine/.idea/misc.xml | 1 -
src/medicine/.idea/modules.xml | 1 -
.../0bf6f777ae20a7657065bc4a2b2a9f1f3b4876b1 | 0
.../42d62ad23989879b1e669e84287f32b9ec3b7df5 | 10 ---
.../5aa79857db1807fe40f0941af9e17d8a19d8bc97 | 0
.../5feb9f75e1bc678660918562fd0ce2745899be29 | 21 ------
.../762bc359bc75ba7b3073e784c826f31f6c989305 | 2 -
.../7f8771ebddaacf6a70143dc43243816aa7f7e066 | 20 ------
.../b7cd5493e06e5fd9d49343a72ed251284cff7045 | 8 ---
.../be5bf7d32cedc052850e2cc0c99f2cf7357cac12 | 2 -
.../edeacc9d294f3b307d4238fb3f381c6838218bb6 | 7 --
.../.idea/sonarlint/issuestore/index.pb | 24 +------
.../0bf6f777ae20a7657065bc4a2b2a9f1f3b4876b1 | 0
.../42d62ad23989879b1e669e84287f32b9ec3b7df5 | 0
.../5aa79857db1807fe40f0941af9e17d8a19d8bc97 | 0
.../5feb9f75e1bc678660918562fd0ce2745899be29 | 0
.../762bc359bc75ba7b3073e784c826f31f6c989305 | 0
.../7f8771ebddaacf6a70143dc43243816aa7f7e066 | 0
.../b7cd5493e06e5fd9d49343a72ed251284cff7045 | 0
.../be5bf7d32cedc052850e2cc0c99f2cf7357cac12 | 0
.../edeacc9d294f3b307d4238fb3f381c6838218bb6 | 0
.../sonarlint/securityhotspotstore/index.pb | 24 +------
.../Service/CancerDetectService.java | 3 +
.../Service/PersonalHomeService.java | 41 +++++++++--
.../springboot/Service/WebHomeService.java | 72 +++++++++++++++----
.../src/main/java/org/example/Main.java | 24 +++++++
.../java/org/example/python/output_result.py | 32 +++++++++
.../src/main/java/org/example/runmodel.java | 30 ++++++++
29 files changed, 189 insertions(+), 134 deletions(-)
delete mode 100644 src/medicine/.idea/sonarlint/issuestore/0/b/0bf6f777ae20a7657065bc4a2b2a9f1f3b4876b1
delete mode 100644 src/medicine/.idea/sonarlint/issuestore/4/2/42d62ad23989879b1e669e84287f32b9ec3b7df5
delete mode 100644 src/medicine/.idea/sonarlint/issuestore/5/a/5aa79857db1807fe40f0941af9e17d8a19d8bc97
delete mode 100644 src/medicine/.idea/sonarlint/issuestore/5/f/5feb9f75e1bc678660918562fd0ce2745899be29
delete mode 100644 src/medicine/.idea/sonarlint/issuestore/7/6/762bc359bc75ba7b3073e784c826f31f6c989305
delete mode 100644 src/medicine/.idea/sonarlint/issuestore/7/f/7f8771ebddaacf6a70143dc43243816aa7f7e066
delete mode 100644 src/medicine/.idea/sonarlint/issuestore/b/7/b7cd5493e06e5fd9d49343a72ed251284cff7045
delete mode 100644 src/medicine/.idea/sonarlint/issuestore/b/e/be5bf7d32cedc052850e2cc0c99f2cf7357cac12
delete mode 100644 src/medicine/.idea/sonarlint/issuestore/e/d/edeacc9d294f3b307d4238fb3f381c6838218bb6
delete mode 100644 src/medicine/.idea/sonarlint/securityhotspotstore/0/b/0bf6f777ae20a7657065bc4a2b2a9f1f3b4876b1
delete mode 100644 src/medicine/.idea/sonarlint/securityhotspotstore/4/2/42d62ad23989879b1e669e84287f32b9ec3b7df5
delete mode 100644 src/medicine/.idea/sonarlint/securityhotspotstore/5/a/5aa79857db1807fe40f0941af9e17d8a19d8bc97
delete mode 100644 src/medicine/.idea/sonarlint/securityhotspotstore/5/f/5feb9f75e1bc678660918562fd0ce2745899be29
delete mode 100644 src/medicine/.idea/sonarlint/securityhotspotstore/7/6/762bc359bc75ba7b3073e784c826f31f6c989305
delete mode 100644 src/medicine/.idea/sonarlint/securityhotspotstore/7/f/7f8771ebddaacf6a70143dc43243816aa7f7e066
delete mode 100644 src/medicine/.idea/sonarlint/securityhotspotstore/b/7/b7cd5493e06e5fd9d49343a72ed251284cff7045
delete mode 100644 src/medicine/.idea/sonarlint/securityhotspotstore/b/e/be5bf7d32cedc052850e2cc0c99f2cf7357cac12
delete mode 100644 src/medicine/.idea/sonarlint/securityhotspotstore/e/d/edeacc9d294f3b307d4238fb3f381c6838218bb6
create mode 100644 src/medicine/test_model/src/main/java/org/example/Main.java
create mode 100644 src/medicine/test_model/src/main/java/org/example/python/output_result.py
create mode 100644 src/medicine/test_model/src/main/java/org/example/runmodel.java
diff --git a/src/medicine/.idea/compiler.xml b/src/medicine/.idea/compiler.xml
index ff4c146f..12b36f50 100644
--- a/src/medicine/.idea/compiler.xml
+++ b/src/medicine/.idea/compiler.xml
@@ -7,7 +7,6 @@
-
diff --git a/src/medicine/.idea/misc.xml b/src/medicine/.idea/misc.xml
index 3777a728..e7904b37 100644
--- a/src/medicine/.idea/misc.xml
+++ b/src/medicine/.idea/misc.xml
@@ -4,7 +4,6 @@
diff --git a/src/medicine/.idea/modules.xml b/src/medicine/.idea/modules.xml
index fd610834..a6cf5887 100644
--- a/src/medicine/.idea/modules.xml
+++ b/src/medicine/.idea/modules.xml
@@ -4,7 +4,6 @@
-
\ No newline at end of file
diff --git a/src/medicine/.idea/sonarlint/issuestore/0/b/0bf6f777ae20a7657065bc4a2b2a9f1f3b4876b1 b/src/medicine/.idea/sonarlint/issuestore/0/b/0bf6f777ae20a7657065bc4a2b2a9f1f3b4876b1
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/medicine/.idea/sonarlint/issuestore/4/2/42d62ad23989879b1e669e84287f32b9ec3b7df5 b/src/medicine/.idea/sonarlint/issuestore/4/2/42d62ad23989879b1e669e84287f32b9ec3b7df5
deleted file mode 100644
index fd5965c8..00000000
--- a/src/medicine/.idea/sonarlint/issuestore/4/2/42d62ad23989879b1e669e84287f32b9ec3b7df5
+++ /dev/null
@@ -1,10 +0,0 @@
-
-{ java:S120"ZRename this package name to match the regular expression '^[a-z_]+(\.[a-z_][a-z0-9_]*)*$'.(81
-l
-java:S4488"JReplace "@RequestMapping(method = RequestMethod.POST)" with "@PostMapping"(81
-g
-java:S4488"JReplace "@RequestMapping(method = RequestMethod.POST)" with "@PostMapping"(ޕ81
-l
-java:S4488+"JReplace "@RequestMapping(method = RequestMethod.POST)" with "@PostMapping"(Î81
-g
-java:S44881"JReplace "@RequestMapping(method = RequestMethod.POST)" with "@PostMapping"(ՠ8Ŀ1
\ No newline at end of file
diff --git a/src/medicine/.idea/sonarlint/issuestore/5/a/5aa79857db1807fe40f0941af9e17d8a19d8bc97 b/src/medicine/.idea/sonarlint/issuestore/5/a/5aa79857db1807fe40f0941af9e17d8a19d8bc97
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/medicine/.idea/sonarlint/issuestore/5/f/5feb9f75e1bc678660918562fd0ce2745899be29 b/src/medicine/.idea/sonarlint/issuestore/5/f/5feb9f75e1bc678660918562fd0ce2745899be29
deleted file mode 100644
index 9dbd7a70..00000000
--- a/src/medicine/.idea/sonarlint/issuestore/5/f/5feb9f75e1bc678660918562fd0ce2745899be29
+++ /dev/null
@@ -1,21 +0,0 @@
-
-Q
-java:S3740"/Provide the parametrized type for this generic.(8ɸ1
-{ java:S120"ZRename this package name to match the regular expression '^[a-z_]+(\.[a-z_][a-z0-9_]*)*$'.(8ɸ1
-Z java:S106,"9Replace this use of System.out or System.err by a logger.(8ɸ1
-Z java:S106-"9Replace this use of System.out or System.err by a logger.(˼8ɸ1
-U java:S106="9Replace this use of System.out or System.err by a logger.(ވ8ɸ1
-U java:S106K"9Replace this use of System.out or System.err by a logger.(8ɸ1
-Z java:S106b"9Replace this use of System.out or System.err by a logger.(8ɸ1
-T java:S106c"9Replace this use of System.out or System.err by a logger.(ƴ78ɸ1
-Z java:S106r"9Replace this use of System.out or System.err by a logger.(㘘8ɸ1
-U java:S106"9Replace this use of System.out or System.err by a logger.(¼8ɸ1
-U java:S106"9Replace this use of System.out or System.err by a logger.(ܝ8ɸ1
-[ java:S106"9Replace this use of System.out or System.err by a logger.(Я8ɸ1
-V java:S106"9Replace this use of System.out or System.err by a logger.(8ɸ1
-V java:S106"9Replace this use of System.out or System.err by a logger.(ɂ8ɸ1
-n
-java:S1128 "LRemove this unused import 'org.springframework.cache.annotation.CacheEvict'.(8ɸ1
-l
-java:S1128
-"JRemove this unused import 'org.springframework.cache.annotation.CachePut'.(≠8ɸ1
\ No newline at end of file
diff --git a/src/medicine/.idea/sonarlint/issuestore/7/6/762bc359bc75ba7b3073e784c826f31f6c989305 b/src/medicine/.idea/sonarlint/issuestore/7/6/762bc359bc75ba7b3073e784c826f31f6c989305
deleted file mode 100644
index 4a81afc1..00000000
--- a/src/medicine/.idea/sonarlint/issuestore/7/6/762bc359bc75ba7b3073e784c826f31f6c989305
+++ /dev/null
@@ -1,2 +0,0 @@
-
-{ java:S120"ZRename this package name to match the regular expression '^[a-z_]+(\.[a-z_][a-z0-9_]*)*$'.(81
\ No newline at end of file
diff --git a/src/medicine/.idea/sonarlint/issuestore/7/f/7f8771ebddaacf6a70143dc43243816aa7f7e066 b/src/medicine/.idea/sonarlint/issuestore/7/f/7f8771ebddaacf6a70143dc43243816aa7f7e066
deleted file mode 100644
index 1a0ddc9b..00000000
--- a/src/medicine/.idea/sonarlint/issuestore/7/f/7f8771ebddaacf6a70143dc43243816aa7f7e066
+++ /dev/null
@@ -1,20 +0,0 @@
-
-` java:S112$"FDefine and throw a dedicated exception instead of using a generic one.(҂
-k java:S117"QRename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(硾
-f java:S117"QRename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(ų
-k java:S117"QRename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(
-t
-java:S2142#"^Either re-interrupt this method or rethrow the "InterruptedException" that can be caught here.(䠹
-N java:S106"9Replace this use of System.out or System.err by a logger.(̓
-R
-java:S1128"7Remove this unused import 'org.python.core.PyFunction'.(忎
-P
-java:S1128"5Remove this unused import 'org.python.core.PyObject'.(
-P
-java:S1128"5Remove this unused import 'org.python.core.PyString'.(ܔ
-T
-java:S1128">Remove this unused import 'org.python.util.PythonInterpreter'.(
-M
-java:S1128"7Remove this unused import 'javax.imageio.IIOException'.(ϒ
-F
-java:S1128"0Remove this unused import 'java.util.ArrayList'.(
\ No newline at end of file
diff --git a/src/medicine/.idea/sonarlint/issuestore/b/7/b7cd5493e06e5fd9d49343a72ed251284cff7045 b/src/medicine/.idea/sonarlint/issuestore/b/7/b7cd5493e06e5fd9d49343a72ed251284cff7045
deleted file mode 100644
index 926c89b7..00000000
--- a/src/medicine/.idea/sonarlint/issuestore/b/7/b7cd5493e06e5fd9d49343a72ed251284cff7045
+++ /dev/null
@@ -1,8 +0,0 @@
-
-{ java:S120"ZRename this package name to match the regular expression '^[a-z_]+(\.[a-z_][a-z0-9_]*)*$'.(8Ҹ1
-l
-java:S1128"ORemove this unused import 'org.springframework.beans.factory.annotation.Value'.(8Ҹ1
-r
-java:S1128 "PRemove this unused import 'org.springframework.web.bind.annotation.RequestBody'.(⭽8Ҹ1
-F
-java:S1128")Remove this unused import 'java.io.File'.(Х8Ҹ1
\ No newline at end of file
diff --git a/src/medicine/.idea/sonarlint/issuestore/b/e/be5bf7d32cedc052850e2cc0c99f2cf7357cac12 b/src/medicine/.idea/sonarlint/issuestore/b/e/be5bf7d32cedc052850e2cc0c99f2cf7357cac12
deleted file mode 100644
index 25a5fa64..00000000
--- a/src/medicine/.idea/sonarlint/issuestore/b/e/be5bf7d32cedc052850e2cc0c99f2cf7357cac12
+++ /dev/null
@@ -1,2 +0,0 @@
-
-t java:S120"ZRename this package name to match the regular expression '^[a-z_]+(\.[a-z_][a-z0-9_]*)*$'.(
\ No newline at end of file
diff --git a/src/medicine/.idea/sonarlint/issuestore/e/d/edeacc9d294f3b307d4238fb3f381c6838218bb6 b/src/medicine/.idea/sonarlint/issuestore/e/d/edeacc9d294f3b307d4238fb3f381c6838218bb6
deleted file mode 100644
index d18aa71f..00000000
--- a/src/medicine/.idea/sonarlint/issuestore/e/d/edeacc9d294f3b307d4238fb3f381c6838218bb6
+++ /dev/null
@@ -1,7 +0,0 @@
-
-{ java:S120"ZRename this package name to match the regular expression '^[a-z_]+(\.[a-z_][a-z0-9_]*)*$'.(81
-h
-java:S1128 "KRemove this unused import 'org.springframework.cache.annotation.Cacheable'.(ݺؓ8ฬ1
-p
-java:S1128
-"NRemove this unused import 'org.springframework.data.redis.core.RedisTemplate'.(8ฬ1
\ No newline at end of file
diff --git a/src/medicine/.idea/sonarlint/issuestore/index.pb b/src/medicine/.idea/sonarlint/issuestore/index.pb
index a8e45a57..31915749 100644
--- a/src/medicine/.idea/sonarlint/issuestore/index.pb
+++ b/src/medicine/.idea/sonarlint/issuestore/index.pb
@@ -17,43 +17,23 @@ X
0train_cancer/train_model/data_gen/data_output.py,6\9\69a341fae4073fedbb8b01a3b078c3012c70ce5f
}
Mspringboot/src/main/java/com/xht/springboot/Control/GetSpiderInformation.java,6\a\6ae8bd6e0b13a9d9272e5cd44460d2d0a72091d9
-^
-.test_model/src/main/java/org/example/Main.java,7\f\7f8771ebddaacf6a70143dc43243816aa7f7e066
r
Bspringboot/src/main/java/com/xht/springboot/Tip/RequestResult.java,8\a\8ac776bbbb6e77f29694ccc4476b533f9f4573da
-|
-Lspringboot/src/main/java/com/xht/springboot/Service/CancerDetectService.java,5\a\5aa79857db1807fe40f0941af9e17d8a19d8bc97
C
springboot/mvnw.cmd,a\0\a027316d6320e979eb2d643acc8d7431b5899762
B
test_model/pom.xml,c\5\c5247f1a7a8da981f49c6fe2b5fc0ba5e9b426bb
-p
-@springboot/src/main/java/com/xht/springboot/Entity/UserHome.java,0\b\0bf6f777ae20a7657065bc4a2b2a9f1f3b4876b1
q
Aspringboot/src/main/java/com/xht/springboot/Entity/UserLogin.java,1\3\139a0da36daad8c438a5607ee212d1f38a505779
B
springboot/pom.xml,e\4\e46aee6c7c512a7b48980a296fca0acf004a1907
r
Bspringboot/src/main/java/com/xht/springboot/Dao/WebHomeMapper.java,2\a\2ad2a1260dac6c01c8b352bb0e2ca62f513676a9
-s
-Cspringboot/src/main/java/com/xht/springboot/Config/RedisConfig.java,0\3\03febb48c6f14848416295ea77d17704b452f798
p
@springboot/src/main/java/com/xht/springboot/Entity/UserText.java,4\0\40a2343a36c9747fa26c52f19f82c0a493b5c2e0
s
Cspringboot/src/main/java/com/xht/springboot/Entity/UserComment.java,9\3\932ae6b8f9f42f924c25e69e48dc30fddd63ec28
q
Aspringboot/src/main/java/com/xht/springboot/Entity/UserReply.java,0\5\051eaf551b928a8ccf651611c070ebb2b8155264
-w
-Gspringboot/src/main/java/com/xht/springboot/Service/WebHomeService.java,5\f\5feb9f75e1bc678660918562fd0ce2745899be29
-
-Ospringboot/src/main/java/com/xht/springboot/Control/CancerDetectController.java,b\7\b7cd5493e06e5fd9d49343a72ed251284cff7045
-z
-Jspringboot/src/main/java/com/xht/springboot/Control/WebHomeController.java,e\d\edeacc9d294f3b307d4238fb3f381c6838218bb6
-
-Ospringboot/src/main/java/com/xht/springboot/Control/PersonalHomeController.java,b\e\be5bf7d32cedc052850e2cc0c99f2cf7357cac12
-|
-Lspringboot/src/main/java/com/xht/springboot/Service/PersonalHomeService.java,7\6\762bc359bc75ba7b3073e784c826f31f6c989305
-v
-Fspringboot/src/main/java/com/xht/springboot/SpringbootApplication.java,4\0\40324953a2003c0d6c6b3ceece38a620d48a0df7
-
-Sspringboot/src/main/java/com/xht/springboot/Control/LoginAndRegisterController.java,4\2\42d62ad23989879b1e669e84287f32b9ec3b7df5
\ No newline at end of file
+l
+ getUserTexts(int uid){
- return personalHomeMapper.findTexts(uid);
+ List userTexts = (List) redisTemplate.opsForValue().get(userTxtByUidCacheName + uid);
+ if(userTexts!=null)
+ return userTexts;
+ else{
+ synchronized (PersonalHomeService.class){
+ userTexts = (List) redisTemplate.opsForValue().get(userTxtByUidCacheName + uid);
+ if(userTexts!=null)
+ return userTexts;
+ else{
+ userTexts = personalHomeMapper.findTexts(uid);
+ if(userTexts!=null)
+ redisTemplate.opsForValue().set(userTxtByUidCacheName+uid,userTexts);
+ return userTexts;
+ }
+ }
+ }
}
}
diff --git a/src/medicine/springboot/src/main/java/com/xht/springboot/Service/WebHomeService.java b/src/medicine/springboot/src/main/java/com/xht/springboot/Service/WebHomeService.java
index 127d8ef3..9358f17b 100644
--- a/src/medicine/springboot/src/main/java/com/xht/springboot/Service/WebHomeService.java
+++ b/src/medicine/springboot/src/main/java/com/xht/springboot/Service/WebHomeService.java
@@ -21,19 +21,53 @@ public class WebHomeService {
WebHomeMapper webHomeMapper;
@Autowired
RedisTemplate redisTemplate;
+ String webHomeDataCacheName = "userTxt&Cmt::";
+ String webHomeDataKey = "all";
+ String userRepliesCacheName = "userRepliesOfCmt::";
String userTxtCacheName = "userTxt::";
String userCmtCacheName = "userCmt::";
String userReplyCacheName = "userReply::";
+ String userFindTxtCacheName = "userFindTxt::";
//获得所有文章除了评论的回复
- @Cacheable(cacheNames = "userTxt&Cmt")
public List getWebHomeData(){
- return webHomeMapper.findAllTextAndComments();
+ List userTexts = (List) redisTemplate.opsForValue().get(webHomeDataCacheName+webHomeDataKey);
+ if(userTexts!=null)
+ return userTexts;
+ else{
+ synchronized (WebHomeService.class){
+ userTexts = (List) redisTemplate.opsForValue().get(webHomeDataCacheName+webHomeDataKey);
+ if(userTexts!=null)
+ return userTexts;
+ else {
+ userTexts = webHomeMapper.findAllTextAndComments();
+ if(userTexts!=null)
+ redisTemplate.opsForValue().set(webHomeDataCacheName+webHomeDataKey,userTexts);
+ return userTexts;
+ }
+ }
+ }
}
- @Cacheable(cacheNames = "userRepliesOfCmt",key = "#p0")
+
+
public List getUserReplies(int commentid){
- return webHomeMapper.findRepliesByCommentId(commentid);
+ List userReplies = (List) redisTemplate.opsForValue().get(userRepliesCacheName+commentid);
+ if(userReplies!=null)
+ return userReplies;
+ else{
+ synchronized (WebHomeService.class){
+ userReplies = (List) redisTemplate.opsForValue().get(userRepliesCacheName+commentid);
+ if(userReplies!=null)
+ return userReplies;
+ else {
+ userReplies = webHomeMapper.findRepliesByCommentId(commentid);
+ if(userReplies!=null)
+ redisTemplate.opsForValue().set(userRepliesCacheName+commentid,userReplies);
+ return userReplies;
+ }
+ }
+ }
}
@@ -53,12 +87,12 @@ public class WebHomeService {
public boolean deleteUserText(UserText userText){
- redisTemplate.opsForValue().getAndDelete(userTxtCacheName+userText.getTextid());//先删除缓存中数据
-
int rows=0;
rows = webHomeMapper.deleteUserText(userText);
if(rows >= 1){
System.out.println("delete text OK "+rows);
+
+ redisTemplate.opsForValue().getAndDelete(userTxtCacheName+userText.getTextid());//删除缓存中数据
return true;
}else{
return false;
@@ -67,12 +101,12 @@ public class WebHomeService {
public boolean updateUserText(UserText userText){
- redisTemplate.opsForValue().getAndDelete(userTxtCacheName+userText.getTextid());//先删除缓存中数据
-
int rows=0;
rows = webHomeMapper.updateUserText(userText);
if(rows >= 1){
System.out.println("update text OK "+rows);
+ redisTemplate.opsForValue().getAndDelete(userTxtCacheName+userText.getTextid());//先删除缓存中数据
+
return true;
}else{
return false;
@@ -80,12 +114,24 @@ public class WebHomeService {
}
@Transactional
- @Cacheable(cacheNames = "userFindTxt",key = "#p0")
public List findUserText(String token){
- List results = null;
- results = webHomeMapper.findOfTextContains(token);//查询文本中是否包含
- results.addAll(webHomeMapper.findOfTitleContains(token));//查询标题中是否包含
- return results;
+ List userTexts = (List) redisTemplate.opsForValue().get(userFindTxtCacheName+token);
+ if(userTexts!=null)
+ return userTexts;
+ else{
+ synchronized (WebHomeService.class){
+ userTexts = (List) redisTemplate.opsForValue().get(userFindTxtCacheName+token);
+ if(userTexts!=null)
+ return userTexts;
+ else{
+ userTexts = webHomeMapper.findOfTextContains(token);//查询文本中是否包含
+ userTexts.addAll(webHomeMapper.findOfTitleContains(token));//查询标题中是否包含
+ if(userTexts!=null)
+ redisTemplate.opsForValue().set(userFindTxtCacheName+token,userTexts);
+ return userTexts;
+ }
+ }
+ }
}
diff --git a/src/medicine/test_model/src/main/java/org/example/Main.java b/src/medicine/test_model/src/main/java/org/example/Main.java
new file mode 100644
index 00000000..eaf28e73
--- /dev/null
+++ b/src/medicine/test_model/src/main/java/org/example/Main.java
@@ -0,0 +1,24 @@
+package org.example;
+
+import org.python.core.PyFunction;
+import org.python.core.PyObject;
+import org.python.core.PyString;
+import org.python.util.PythonInterpreter;
+
+import javax.imageio.IIOException;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.example.runmodel.*;
+
+public class Main {
+ public static void main(String[] args) throws IOException {
+ String dir_pic = "E:\\Git project\\medicine\\src\\medicine\\springboot\\src\\main\\resources\\upload\\cancerpictures";
+ String res = runmodel.get_percent(dir_pic);
+ System.out.println(res);
+ }
+}
\ No newline at end of file
diff --git a/src/medicine/test_model/src/main/java/org/example/python/output_result.py b/src/medicine/test_model/src/main/java/org/example/python/output_result.py
new file mode 100644
index 00000000..4a8f4f7e
--- /dev/null
+++ b/src/medicine/test_model/src/main/java/org/example/python/output_result.py
@@ -0,0 +1,32 @@
+import numpy as np
+import cv2
+from PIL import Image
+import tensorflow as tf
+import sys
+
+def load_single(dir , size):
+ read = lambda i: np.asarray(Image.open(i).convert("RGB"))
+ path = dir
+ img = read(path)
+ return np.array(cv2.resize(img, (size, size)))
+
+def check(dir_pic , dir_model):
+ pic_test = dir_pic
+ # 转换为numpy格式
+ img_test = load_single(pic_test , 224)
+ # 需要(1,224,224,3)这种格式输入
+ img_test = np.expand_dims(img_test , axis=0)
+
+ # 载入模型
+ x = tf.keras.models.load_model(dir_model)
+ res = x.predict(img_test)
+ np.set_printoptions(suppress=True)
+ return f'{res[0][0] * 100 : .4f}%,{res[0][1] * 100 : .4f}%'
+
+
+if __name__ == '__main__':
+ a = []
+ for i in range(1, len(sys.argv)):
+ a.append(sys.argv[i])
+
+ print(check(a[0] , a[1]))
\ No newline at end of file
diff --git a/src/medicine/test_model/src/main/java/org/example/runmodel.java b/src/medicine/test_model/src/main/java/org/example/runmodel.java
new file mode 100644
index 00000000..131de485
--- /dev/null
+++ b/src/medicine/test_model/src/main/java/org/example/runmodel.java
@@ -0,0 +1,30 @@
+package org.example;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+public class runmodel {
+
+ public static String get_percent(String dir_pic) throws IOException {
+ // 自行设置相对路径即可
+ String dir_model = "test_model/src/main/java/org/example/model";
+ String py_dir = "test_model/src/main/java/org/example/python/output_result.py";
+
+ /**
+ * py_dir output_result文件所在位置
+ * dir_pic 图片位置
+ * dir_model 模型的位置
+ */
+ String[] path = new String[]{"python " , py_dir , dir_pic , dir_model};
+ Process proc = Runtime.getRuntime().exec(path);
+
+ BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
+ String line = null;
+ String temp = null;
+ while ((line = in.readLine()) != null) temp = line;
+ assert temp != null;
+ String[] t = temp.split(",");
+ return "良性:" + t[0] + " 恶性:" + t[1];
+ }
+}
\ No newline at end of file