提交 2ddf50c9 authored 作者: zhangshuang's avatar zhangshuang

zs

......@@ -25,10 +25,10 @@
</dependency>
<!--webSocket 后台向前端推送消息-->
<!--<dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>-->
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
......@@ -95,11 +95,11 @@
<artifactId>commons-compress</artifactId>
<version>1.8.1</version>
</dependency>
<!-- <dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-websocket</artifactId>
&lt;!&ndash; <version>4.3.17.RELEASE</version>&ndash;&gt;
</dependency>-->
<!-- <version>4.3.17.RELEASE</version>-->
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
......@@ -131,6 +131,11 @@
<artifactId>snakeyaml</artifactId>
<version>1.25</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.apache.zookeeper</groupId>-->
<!-- <artifactId>zookeeper</artifactId>-->
<!-- <version>3.3.4</version>-->
<!-- </dependency>-->
<dependency>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
......@@ -155,14 +160,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
......
......@@ -69,6 +69,7 @@ public class WebSocketServer {
this.session.getBasicRemote().sendText(message);
}
public static void sendIn(String sessionId,String message) throws IOException {
//System.out.println(message);
try {
map.get(sessionId).sendMessage(message);
}catch (Exception e){
......
......@@ -32,6 +32,7 @@ public class Rule {
//private MatchType pathMatchType;//文件匹配方式 路径/文件名/后缀
private String path;//文件路径匹配
private String des;
//private TextMatch textMatching;//文本匹配方式 全文匹配/正则匹配
//private DealWay dealWay;//替换,在匹配字之前插入,在匹配字之后插入
......
package com.zjty.adaptationmaster.base.enums;
import org.apache.tomcat.websocket.server.WsFilter;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
......@@ -44,7 +41,7 @@ public class Const {
public static Map<String,Long> transferCountMap = new ConcurrentHashMap<>();
public static final String MAVENHOME = "D:\\Program Files\\apache-maven-3.5.4-bin\\apache-maven-3.5.4";
public static final String MAVENHOME = "/opt/apache-maven-3.5.4";
public static final String CTLPATH = "/home/taiyuan/桌面/AAS-V9.0/bin/appctl";
public static final String CTLPWD = "Qwert123!@#";
}
......@@ -11,6 +11,8 @@ import com.zjty.adaptationmaster.base.response.ServerResponse;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -27,11 +29,12 @@ import java.util.regex.Pattern;
@Component
public class Adaptor {
Logger logger = LoggerFactory.getLogger(getClass());
//@Autowired
//private AdaptationDetailLogEntityDao adaptationDetailLogEntityDao;
@Autowired
private OriginalFileDao originalFileDao;
@Autowired
private ProjectDao projectDao;
private String uuid;
......@@ -107,8 +110,10 @@ public class Adaptor {
}
if(match) {
System.out.println("match");
System.out.println(file);
// logger.info();
// System.out.println("match");
// System.out.println(file);
//logger.info("找到文件"+file.getFileName());
String storePath = storePathParent+"/"+UUID.randomUUID().toString()+"/"+file.getFileName();
//原先文件的新地址
Path originalPath = Paths.get(basePath +storePath);
......@@ -119,7 +124,7 @@ public class Adaptor {
//Files.copy(file,originalPath);
Files.move(file, originalPath);
//splitedFile.setDeal(true);
WebSocketServer.sendIn(uuid,TimeUtil.getNowDate()+"内容替换:过滤文件"+project.getProjectName());
//WebSocketServer.sendIn(uuid,TimeUtil.getNowDate()+"内容替换:过滤文件"+project.getProjectName()+file.getFileName());
//System.out.println();
if (attrs.size() > LIMIT) {
System.out.println("找到大文件" + file);
......
......@@ -37,7 +37,7 @@ public class ApusicDeployer {
outputStream.write(password.getBytes());
outputStream.flush();
outputStream.close();
BufferedReader reader = new BufferedReader(new InputStreamReader(exec.getInputStream(),"GBK"));
BufferedReader reader = new BufferedReader(new InputStreamReader(exec.getInputStream(),"UTF-8"));
boolean titleEnd = false;
String line = null;
while ((line = reader.readLine()) != null) {
......@@ -80,7 +80,7 @@ public class ApusicDeployer {
outputStream.write(password.getBytes());
outputStream.flush();
outputStream.close();
BufferedReader reader = new BufferedReader(new InputStreamReader(exec.getInputStream(),"GBK"));
BufferedReader reader = new BufferedReader(new InputStreamReader(exec.getInputStream(),"UTF-8"));
String line = null;
while ((line = reader.readLine()) != null) {
WebSocketServer.sendIn(webSocketName, TimeUtil.getNowDate()+"自动部署:"+ projectName+line);
......
......@@ -24,6 +24,10 @@ public class MavenCompiler {
public void compiler(){
System.out.print("wwwwwww");
InvocationRequest request1 = new DefaultInvocationRequest();
request1.setPomFile(new File(project.getReport().getCompileFilePath()));
request1.setGoals(Collections.singletonList("clean"));
InvocationRequest request = new DefaultInvocationRequest();
request.setPomFile(new File(project.getReport().getCompileFilePath()));
request.setGoals(Collections.singletonList("package"));
......@@ -39,6 +43,7 @@ public class MavenCompiler {
}
});
try {
invoker.execute(request1);
InvocationResult execute = invoker.execute(request);
CommandLineException executionException = execute.getExecutionException();
if(executionException==null){
......
......@@ -6,6 +6,8 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.tomcat.websocket.server.WsServerContainer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.nio.file.Path;
......@@ -16,6 +18,7 @@ import java.util.Properties;
public class ReadedFileTask implements Runnable {
Logger logger = LoggerFactory.getLogger(getClass());
private String projectName;
private String uuid;
......@@ -42,10 +45,11 @@ public class ReadedFileTask implements Runnable {
@Override
public void run() {
System.out.println("进来线程");
//System.out.println("进来线程");
for(ReadedFile readedFile:readedFiles) {
boolean match = false;
String content = readedFile.getContent();
System.out.println("规则数量" + readedFile.getThisMatchedRule().size());
//System.out.println("规则数量" + readedFile.getThisMatchedRule().size());
for (Rule entity : readedFile.getThisMatchedRule()) {
//在改动的地方加日志
// int i = content.indexOf(entity.getTarget());
......@@ -54,6 +58,7 @@ public class ReadedFileTask implements Runnable {
String replace = entity.getReplacing();
String[] split;
if(replace.contains("*")) {
logger.info("目标文本包含*,要记录*中的内容");
split = entity.getTarget().split("\\*");
int i = content.indexOf(split[0]);
int i1 = content.indexOf(split[1], i + split[0].length());
......@@ -62,17 +67,34 @@ public class ReadedFileTask implements Runnable {
replace = split1[0]+temp+split1[1];
content = content.substring(0,i)+replace+content.substring(i1);
}else {
if(content.contains(entity.getTarget())){
try {
WebSocketServer.sendIn(uuid,TimeUtil.getNowDate() + " 代码替换:在文件" + readedFile.getPath().getFileName() + "中,找到关键字:\""+entity.getTarget()+"\",替换为"+replace);//"替换文件,找到文件"+ readedFile.getPath().getFileName());
} catch (IOException e) {
e.printStackTrace();
}
match = true;
logger.info("找到目标"+readedFile.getPath().getFileName()+"目标:"+entity.getTarget());
}
content = content.replaceAll(entity.getTarget(), replace);
// if(match){
// logger.info(content);
// }
}
System.out.println("处理完成");
//System.out.println("处理完成");
}
try {
if (bySort != null) {
System.out.println("bysort");
//System.out.println("bysort");
bySort.insert(index, content);
} else {
System.out.println("notbysort");
WebSocketServer.sendIn(uuid, TimeUtil.getNowDate()+"内容替换:文件写出"+readedFile.getPath().getFileName());
//System.out.println("notbysort");
//logger.info(TimeUtil.getNowDate()+"内容替换:文件写出"+readedFile.getPath().getFileName());
if(match) {
//System.out.println(TimeUtil.getNowDate() + "内容替换:文件正在写出" + readedFile.getPath().getFileName());
//WebSocketServer.sendIn(uuid, TimeUtil.getNowDate() + "内容替换:文件写出" + readedFile.getPath().getFileName());
}
File file = readedFile.getPath().toFile();
file.createNewFile();
OutputStreamWriter contentWriter = new OutputStreamWriter(new FileOutputStream(file));
......@@ -82,7 +104,6 @@ public class ReadedFileTask implements Runnable {
} catch (IOException e) {
e.printStackTrace();
}
}
}
......
# mysql数据库配置
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/adaptation?useSSL=false&serverTimezone=UTC&characterEncoding=utf-8
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5866/adaptation?useSSL=false&serverTimezone=UTC&characterEncoding=utf-8
spring.datasource.username=sysdba
spring.datasource.password=highgo@123
package com.zjty.adaptationmaster;
import com.zjty.adaptationmaster.adaptor.entity.Project;
import com.zjty.adaptationmaster.adaptor.entity.Rule;
import com.zjty.adaptationmaster.utils.Adaptor;
import java.util.ArrayList;
import java.util.List;
public class TestDemo {
public static void main(String[] args) {
Rule rule = new Rule();
rule.setPath("*.*");
rule.setTarget("OpenDoc");
rule.setReplacing("OpenOfd");
List ruleList = new ArrayList();
ruleList.add(rule);
Project project = new Project();
project.setCodeUrl("D:\\project\\page1");
project.setProjectName("aaa");
Adaptor adaptor = new Adaptor();
adaptor.setRuleList(ruleList);
adaptor.setProject(project);
adaptor.doAdapt();
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论