| 
					
				 | 
			
			
				@@ -9,6 +9,7 @@ import com.jjt.common.enums.SyncType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.jjt.common.utils.CompressZip; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.jjt.common.utils.FtpUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.jjt.common.utils.LinuxCommand; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.jjt.common.utils.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.jjt.in.service.IInEsService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.jjt.in.service.IInProcessService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.jjt.system.service.ISysConfigService; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -24,7 +25,10 @@ import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import javax.annotation.Resource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.io.File; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.io.IOException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.nio.file.CopyOption; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.nio.file.Files; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.nio.file.Paths; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.nio.file.StandardCopyOption; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.Arrays; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.Comparator; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -75,6 +79,15 @@ public class InProcessServiceImpl implements IInProcessService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (!tmpDir.endsWith(Constants.DIR_END)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             tmpDir += "/"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //获取内网同步备份目录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String bakDir = sysConfigService.selectConfigByKey("in.dir.bak"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!bakDir.endsWith(Constants.DIR_END)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            bakDir += "/"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        File bak = new File(bakDir); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        bak.mkdirs(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 创建File对象 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             File dirFile = new File(syncDir); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -98,16 +111,60 @@ public class InProcessServiceImpl implements IInProcessService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 File targetDir = new File(tmpDir + "es/"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 CompressZip.unzip(zipFile, targetDir); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 String esDir = tmpDir + "es/" + desc.getName().split("\\.")[0].split("-")[2]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 esService.parseSyncFile(esDir); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            case php: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            case shell: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                String shellDir = desc.getTarget(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if (StringUtils.isBlank(shellDir)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if (!shellDir.endsWith(Constants.DIR_END)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    shellDir += "/"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                File sd = new File(shellDir); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                sd.mkdirs(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                //复制文件到目标目录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                Files.copy(zipFile.toPath(), Paths.get(shellDir + zipFile.getName())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                //给文件赋执行权限 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                String dataCmd = "chmod +x " + shellDir + zipFile.getName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                LinuxCommand.exec(dataCmd); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            case php: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                String phpDir = desc.getTarget(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if (StringUtils.isBlank(phpDir)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if (!phpDir.endsWith(Constants.DIR_END)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    phpDir += "/"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                File phpFile = new File(phpDir); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                phpFile.mkdirs(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                //解压文件到目标目录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                CompressZip.unzip(zipFile, phpFile); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             case mongo: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            case other: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                String otherDir = desc.getTarget(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if (StringUtils.isBlank(otherDir)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if (!otherDir.endsWith(Constants.DIR_END)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    otherDir += "/"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                File od = new File(otherDir); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                od.mkdirs(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                //复制文件到目标目录,如果存在则覆盖 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                Files.copy(zipFile.toPath(), Paths.get(otherDir + zipFile.getName()), StandardCopyOption.REPLACE_EXISTING); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            case mysql: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            case crontab: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                String cronCmd = "crontab " + zipFile.getPath(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                log.info("添加crontab", cronCmd); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                LinuxCommand.exec(cronCmd); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             default: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        //移动文件到备份目录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        Files.move(file.toPath(), Paths.get(bakDir + file.getName()), StandardCopyOption.REPLACE_EXISTING); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        Files.move(zipFile.toPath(), Paths.get(bakDir + zipFile.getName()), StandardCopyOption.REPLACE_EXISTING); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         System.err.println("这个是错误滴" + desc.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 |