Browse Source

自动脚本

zxm
hanyuqing 7 months ago
parent
commit
cce64e796b
  1. 146
      gyxtp/src/view/create.vue
  2. 2
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/ZhyFileManageController.java
  3. 282
      ruoyi-api/src/main/java/com/ruoyi/api/controller/DocApiController.java

146
gyxtp/src/view/create.vue

@ -13,21 +13,29 @@
</div>
<div class="rightInfo">
<div class="">
<div class="searchInfo">
<div class="" style="margin-top: 3vw">
<div class="group0">
<div>
<el-cascader
v-model="selected1"
:options="cascadeOptions1"
:props="cascaderProps"
@change="handleChange1"
placeholder="请选择方向类"
style="width: 100%; max-width: 300px;"
<el-input-tag style="height: 50px;width: 600px;" v-model="input" clearable placeholder="Please input" />
<el-cascader-panel v-model="selected1"
:options="cascadeOptions1"
:props="cascaderProps"
@change="handleChange1"
placeholder="请选择方向类"
style="width: fit-content;height: 170px"
/>
<!-- <el-cascader-->
<!-- v-model="selected1"-->
<!-- :options="cascadeOptions1"-->
<!-- :props="cascaderProps"-->
<!-- @change="handleChange1"-->
<!-- placeholder="请选择方向类"-->
<!-- style="width: 100%; max-width: 300px;"-->
<!-- />-->
</div>
<div>
<div style="width: 600px;margin-bottom: 20px;display: flex;align-items: center; "
v-for="(item, index) in searchItems1">
<div class="module">
<div class="module1"
v-for="(item, index) in searchItems1">
<div class="input"
:key="index"
:id="'item-' + index">
@ -57,20 +65,20 @@
</div>
</div>
</div>
<div class="searchInfo">
</div>
<div class="group1">
<div>
<el-cascader
v-model="selected2"
:options="cascadeOptions2"
:props="cascaderProps"
@change="handleChange2"
placeholder="请选择业务系统类"
style="width: 100%; max-width: 300px;"
<el-cascader-panel v-model="selected2"
:options="cascadeOptions2"
:props="cascaderProps"
@change="handleChange2"
placeholder="请选择业务系统类"
style="width: fit-content;height: 170px"
/>
</div>
<div>
<div style="width: 600px;margin-bottom: 20px;display: flex;align-items: center; "
<div class="module">
<div class="module1"
v-for="(item, index) in searchItems2">
<div class="input"
:key="index"
@ -102,19 +110,19 @@
</div>
</div>
<div class="searchInfo">
<div class="group2">
<div>
<el-cascader
v-model="selected3"
:options="cascadeOptions3"
:props="cascaderProps"
@change="handleChange3"
placeholder="请选择模型方法类"
style="width: 100%; max-width: 300px;"
<el-cascader-panel v-model="selected3"
:options="cascadeOptions3"
:props="cascaderProps"
@change="handleChange3"
placeholder="请选择模型方法类"
style="width: fit-content;height: 170px"
/>
</div>
<div>
<div style="width: 600px;margin-bottom: 20px;display: flex;align-items: center; "
<div class="module">
<div class="module1"
v-for="(item, index) in searchItems3">
<div class="input"
:key="index"
@ -146,7 +154,11 @@
</div>
</div>
<el-button @click="build" style="margin-left: 200px">构建</el-button>
<div style="text-align: center">
<el-button @click="build">构建</el-button>
<el-button @click="build" style="margin-left: 200px">重置</el-button>
</div>
</div>
</div>
@ -379,7 +391,8 @@ export default {
children: 'children', // `children` children
disabled: 'disabled' //
},
messages:[],
input:[]
};
},
@ -413,22 +426,26 @@ export default {
{
id: res.g01.id,
docTitle: res.g01.name,
children: res.g01.children
children: res.g01.children,
expanded: true
},
{
id: res.g02.id,
docTitle: res.g02.name,
children: res.g02.children
children: res.g02.children,
},
{
id: res.g03.id,
docTitle: res.g03.name,
children: res.g03.children
children: res.g03.children,
},
{
id: res.g04.id,
docTitle: res.g04.name,
children: res.g04.children
children: res.g04.children,
},
]
this.cascadeOptions2 = [
@ -697,13 +714,15 @@ export default {
}
.input-new-tag {
padding: 0px 12px;
padding: 0px 6px;
border:none;
border-radius: 4px;
font-size: 14px;
outline: none;
height: 30px;
margin-left: 0.5vw;
width: 160px;
border-radius: 2vw;
}
.input-new-tag:focus {
@ -736,28 +755,22 @@ export default {
top: 5.4vw;
background-color: #f3f7ff;
position: absolute;
overflow: auto;
}
.input {
width: 350px;
margin-left: 3vw;
height: 30px;
border-radius: 2vw;
background-color: rgba(255, 255, 255, 0.65);
border: 2px solid #0776ff;
text-indent: 1vw;
font-size: 1.2vw;
margin-right: 15px;
padding: 5px 0px;
}
.searchInfo {
margin-top: 8%;
position: relative;
display: flex;
justify-content: center;
}
.input::placeholder {
height: 30px;
@ -858,5 +871,42 @@ export default {
.vue-treeselect__multi-value-item {
font-size: 16px;
}
.module1{
width: 600px;margin-bottom: 19px;display: flex;align-items: center;
}
.group0{
position: relative;
display: flex;
justify-content: center;
margin-bottom: 20px;
}
.group1{
position: relative;
display: flex;
justify-content: center;
margin-bottom: 20px;
}
.group2{
position: relative;
display: flex;
justify-content: center;
margin-bottom: 20px;
}
.module{
height: 170px;
overflow: auto;
}
.group0 .module1:last-of-type {
margin-bottom: 0;
}
.group1 .module1:last-of-type {
margin-bottom: 0;
}
.group2 .module1:last-of-type {
margin-bottom: 0;
}
</style>

2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/ZhyFileManageController.java

@ -703,7 +703,7 @@ public class ZhyFileManageController extends BaseController {
}
zhyFileManageService.wordSplitterOld(null , url +"\\wordSplitter", 0,list);
zhyFileManageService.createIndex(url + "\\wordSplitter", "D:\\project\\gyx\\tupudata\\fileManager\\index");
// zhyFileManageService.createIndex(url + "\\wordSplitter", "D:\\project\\gyx\\tupudata\\fileManager\\index");
test1Mapper.updateParentId(list);

282
ruoyi-api/src/main/java/com/ruoyi/api/controller/DocApiController.java

@ -1084,104 +1084,89 @@ public class DocApiController extends BaseController {
}
@GetMapping("/getTitleByGroup")
public Map getTitleByGroup(HttpServletRequest request) {
String token = request.getHeader("Token");
if (!token.equals("")) {
token = tokenService.parseToken(token).get("login_user_key", String.class);
reushToken.DeletToken(token);
LoginUser loginUser1 = redisCache.getCacheObject("login_tokens:" + token);
if (loginUser1 != null) {
//查询所有一级标题
List<ZhyDoc> g01=test1Mapper.selectDocByLevelByGroup(0l,1l);
List<ZhyDoc> g02=test1Mapper.selectDocByLevelByGroup(0l,2l);
List<ZhyDoc> g03=test1Mapper.selectDocByLevelByGroup(0l,3l);
List<ZhyDoc> g04=test1Mapper.selectDocByLevelByGroup(0l,4l);
//查询所有一级标题
List<ZhyDoc> g01=test1Mapper.selectDocByLevelByGroup(0l,1l);
List<ZhyDoc> g02=test1Mapper.selectDocByLevelByGroup(0l,2l);
List<ZhyDoc> g03=test1Mapper.selectDocByLevelByGroup(0l,3l);
List<ZhyDoc> g04=test1Mapper.selectDocByLevelByGroup(0l,4l);
List<ZhyDoc> g11=test1Mapper.selectDocByLevelByGroup(1l,1l);
List<ZhyDoc> g12=test1Mapper.selectDocByLevelByGroup(1l,2l);
List<ZhyDoc> g13=test1Mapper.selectDocByLevelByGroup(1l,3l);
List<ZhyDoc> g14=test1Mapper.selectDocByLevelByGroup(1l,4l);
List<ZhyDoc> g21=test1Mapper.selectDocByLevelByGroup(2l,1l);
List<ZhyDoc> g22=test1Mapper.selectDocByLevelByGroup(2l,2l);
List<ZhyDoc> g11=test1Mapper.selectDocByLevelByGroup(1l,1l);
List<ZhyDoc> g12=test1Mapper.selectDocByLevelByGroup(1l,2l);
List<ZhyDoc> g13=test1Mapper.selectDocByLevelByGroup(1l,3l);
List<ZhyDoc> g14=test1Mapper.selectDocByLevelByGroup(1l,4l);
Map mapAll=new HashMap<>();
Map map01=new HashMap<>();
map01.put("id",1);
map01.put("name","方向");
map01.put("children",g01);
List<ZhyDoc> g21=test1Mapper.selectDocByLevelByGroup(2l,1l);
List<ZhyDoc> g22=test1Mapper.selectDocByLevelByGroup(2l,2l);
Map map02=new HashMap<>();
map02.put("id",2);
map02.put("name","作战");
map02.put("children",g02);
Map mapAll=new HashMap<>();
Map map01=new HashMap<>();
map01.put("id",1);
map01.put("name","方向");
map01.put("children",g01);
Map map03=new HashMap<>();
map03.put("id",3);
map03.put("name","装备");
map03.put("children",g03);
Map map02=new HashMap<>();
map02.put("id",2);
map02.put("name","作战");
map02.put("children",g02);
Map map04=new HashMap<>();
map04.put("id",4);
map04.put("name","环境");
map04.put("children",g04);
Map map03=new HashMap<>();
map03.put("id",3);
map03.put("name","装备");
map03.put("children",g03);
Map map11=new HashMap<>();
map11.put("id",1);
map11.put("name","业务系统");
map11.put("children",g11);
Map map04=new HashMap<>();
map04.put("id",4);
map04.put("name","环境");
map04.put("children",g04);
Map map12=new HashMap<>();
map12.put("id",2);
map12.put("name","模型库");
map12.put("children",g12);
Map map11=new HashMap<>();
map11.put("id",1);
map11.put("name","业务系统");
map11.put("children",g11);
Map map13=new HashMap<>();
map13.put("id",3);
map13.put("name","规则库");
map13.put("children",g13);
Map map12=new HashMap<>();
map12.put("id",2);
map12.put("name","模型库");
map12.put("children",g12);
Map map14=new HashMap<>();
map14.put("id",4);
map14.put("name","大类数据");
map14.put("children",g14);
Map map13=new HashMap<>();
map13.put("id",3);
map13.put("name","规则库");
map13.put("children",g13);
Map map21=new HashMap<>();
map21.put("id",1);
map21.put("name","模型方法");
map21.put("children",g21);
Map map14=new HashMap<>();
map14.put("id",4);
map14.put("name","大类数据");
map14.put("children",g14);
Map map22=new HashMap<>();
map22.put("id",2);
map22.put("name","指标");
map22.put("children",g22);
Map map21=new HashMap<>();
map21.put("id",1);
map21.put("name","模型方法");
map21.put("children",g21);
Map map22=new HashMap<>();
map22.put("id",2);
map22.put("name","指标");
map22.put("children",g22);
mapAll.put("g01",map01);
mapAll.put("g02",map02);
mapAll.put("g03",map03);
mapAll.put("g04",map04);
mapAll.put("g11",map11);
mapAll.put("g12",map12);
mapAll.put("g13",map13);
mapAll.put("g14",map14);
mapAll.put("g01",map01);
mapAll.put("g02",map02);
mapAll.put("g03",map03);
mapAll.put("g04",map04);
mapAll.put("g21",map21);
mapAll.put("g22",map22);
mapAll.put("g11",map11);
mapAll.put("g12",map12);
mapAll.put("g13",map13);
mapAll.put("g14",map14);
mapAll.put("g21",map21);
mapAll.put("g22",map22);
return mapAll;
} else {
return null;
}
} else {
return null;
}
return mapAll;
}
@Autowired
BuildService buildService;
@ -1244,7 +1229,7 @@ public class DocApiController extends BaseController {
}
@PostMapping("/buildTwo")
public void buildTwo(HttpServletRequest request,@RequestBody Map<String, Object> data) throws JsonProcessingException {
public void buildTwo(HttpServletRequest request,@RequestBody Map<String, Object> data) throws JsonProcessingException, InterruptedException {
System.out.println(data);
// 存储结果:group -> type -> List<Long>(ID 列表)
@ -1450,37 +1435,126 @@ public class DocApiController extends BaseController {
//如果中途嘎了java等待,然后20分钟去访问mysql时间最后一条数据
}
public void goPython(String title1,String title2,List<Map<String, Object>> searchItems) throws JsonProcessingException {
String[] keywords = new String[]{title1, title2};
Map map =new HashMap();
map.put("keywords",keywords);
map.put("searchItems",searchItems);
sendPython(map);
while (pythonService.flag){
// public void goPython(String title1,String title2,List<Map<String, Object>> searchItems) throws JsonProcessingException, InterruptedException {
// String[] keywords = new String[]{title1, title2};
// Map map =new HashMap();
// map.put("keywords",keywords);
// map.put("searchItems",searchItems);
// sendPython(map);
// while (pythonService.flag){
//
// }
// pythonService.flag=true;
// System.out.println("22222222222222222222");
// System.out.println(pythonService.pythonMessage);
// String payload=pythonService.pythonMessage;
// ObjectMapper mapper=new ObjectMapper();
// Map<String,String> objMap =mapper.readValue(payload, new TypeReference<Map<String, String>>() {});
// if(objMap.get("code").equals("500")){
// System.out.println(objMap.get("message"));
// Thread.sleep(10 * 60 * 1000);
// }
// if(objMap.get("code").equals("200")){
// if (objMap.get("function_name").equals("build")){
// System.out.println("1111111111111");
// System.out.println(objMap);
// staticBuildService.create(objMap);
// }
// if (objMap.get("function_name").equals("none")){
//// staticBuildService.create(objMap);
// System.out.println("没有数据");
// }
// }
// }
public void goPython(String title1, String title2, List<Map<String, Object>> searchItems)
throws JsonProcessingException, InterruptedException {
}
pythonService.flag=false;
System.out.println("22222222222222222222");
System.out.println(pythonService.pythonMessage);
String payload=pythonService.pythonMessage;
ObjectMapper mapper=new ObjectMapper();
Map<String,String> objMap =mapper.readValue(payload, new TypeReference<Map<String, String>>() {});
if(objMap.get("code").equals("500")){
System.out.println(objMap.get("message"));
}
if(objMap.get("code").equals("200")){
if (objMap.get("function_name").equals("build")){
System.out.println("1111111111111");
System.out.println(objMap);
staticBuildService.create(objMap);
String[] keywords = new String[]{title1, title2};
int maxRetries = 3; // 最大重试次数,避免无限重试
int retryCount = 0;
while (retryCount <= maxRetries) {
try {
// 构建请求数据
Map<String, Object> map = new HashMap<>();
map.put("keywords", keywords);
map.put("searchItems", searchItems);
// 发送请求给 Python
sendPython(map);
// 等待 Python 执行完成(通过 flag 控制)
while (pythonService.flag) {
Thread.sleep(1000); // 每秒检查一次,避免忙等
}
// 标志位重置(假设下次调用前需要手动重置)
pythonService.flag = true;
System.out.println("从 Python 收到响应: " + pythonService.pythonMessage);
String payload = pythonService.pythonMessage;
// 解析 JSON 响应
ObjectMapper mapper = new ObjectMapper();
Map<String, String> objMap = mapper.readValue(payload, new TypeReference<Map<String, String>>() {});
// 检查响应状态
if ("500".equals(objMap.get("code"))) {
System.out.println("Python 执行失败: " + objMap.get("message"));
retryCount++;
if (retryCount > maxRetries) {
System.out.println("已达到最大重试次数,放弃重试。");
break;
}
System.out.println("将在 10 分钟后重试... (第 " + retryCount + " 次重试)");
Thread.sleep(10 * 60 * 1000); // 等待 10 分钟后重试
continue; // 重要:跳回循环开头,重新执行整个流程
}
// 成功响应
if ("200".equals(objMap.get("code"))) {
String functionName = objMap.get("function_name");
if ("build".equals(functionName)) {
System.out.println("执行 build 逻辑...");
staticBuildService.create(objMap);
} else if ("none".equals(functionName)) {
System.out.println("Python 返回:没有数据");
} else {
System.out.println("未知的 function_name: " + functionName);
}
// 成功处理,跳出循环
break;
}
if (objMap.get("function_name").equals("none")){
// staticBuildService.create(objMap);
System.out.println("没有数据");
// 如果 code 既不是 200 也不是 500,也应重试
System.out.println("收到未知响应 code: " + objMap.get("code") + ", 消息: " + objMap.get("message"));
retryCount++;
if (retryCount > maxRetries) {
System.out.println("未知响应,已达到最大重试次数。");
break;
}
Thread.sleep(10 * 60 * 1000);
continue;
} catch (IOException e) {
// 处理 JSON 解析异常等
System.err.println("处理 Python 响应时发生错误: " + e.getMessage());
retryCount++;
if (retryCount > maxRetries) break;
Thread.sleep(10 * 60 * 1000);
continue;
} catch (Exception e) {
// 其他潜在异常,如 sendPython 抛出的异常
System.err.println("调用 Python 时发生异常: " + e.getMessage());
retryCount++;
if (retryCount > maxRetries) break;
Thread.sleep(10 * 60 * 1000);
continue;
}
}
System.out.println("goPython 流程结束。");
}
public List<Long> getIdsByGroupAndType(
Map<String, Map<Object, List<Long>>> result,
String groupName,

Loading…
Cancel
Save