| 
														
															@@ -3,6 +3,7 @@ package com.its.vms.api.service; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.its.app.utils.ItsUtils; 
														 | 
														
														 | 
														
															 import com.its.app.utils.ItsUtils; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.its.app.utils.SysUtils; 
														 | 
														
														 | 
														
															 import com.its.app.utils.SysUtils; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.its.vms.api.dto.VmsControlDto; 
														 | 
														
														 | 
														
															 import com.its.vms.api.dto.VmsControlDto; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import com.its.vms.config.ApplicationConfig; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.its.vms.dao.mapper.VmsCtlrMapper; 
														 | 
														
														 | 
														
															 import com.its.vms.dao.mapper.VmsCtlrMapper; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.its.vms.domain.NET; 
														 | 
														
														 | 
														
															 import com.its.vms.domain.NET; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.its.vms.dto.TbVmsCtlrDto; 
														 | 
														
														 | 
														
															 import com.its.vms.dto.TbVmsCtlrDto; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -15,11 +16,16 @@ import lombok.RequiredArgsConstructor; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import lombok.extern.slf4j.Slf4j; 
														 | 
														
														 | 
														
															 import lombok.extern.slf4j.Slf4j; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.springframework.stereotype.Service; 
														 | 
														
														 | 
														
															 import org.springframework.stereotype.Service; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import java.io.File; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import java.io.FileOutputStream; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import java.io.IOException; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 @Slf4j 
														 | 
														
														 | 
														
															 @Slf4j 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 @RequiredArgsConstructor 
														 | 
														
														 | 
														
															 @RequiredArgsConstructor 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 @Service 
														 | 
														
														 | 
														
															 @Service 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 public class VmsControlService { 
														 | 
														
														 | 
														
															 public class VmsControlService { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    private final ApplicationConfig config; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     private final VmsCtlrMapper mapper; 
														 | 
														
														 | 
														
															     private final VmsCtlrMapper mapper; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     private final AppRepositoryService repoService; 
														 | 
														
														 | 
														
															     private final AppRepositoryService repoService; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -313,4 +319,32 @@ public class VmsControlService { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         return statusControlReq(req.getUserId(), command, controlHeater); 
														 | 
														
														 | 
														
															         return statusControlReq(req.getUserId(), command, controlHeater); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    /** 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     * 파일 업로드(동영상 파일) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     * @param symbLibNmbr 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     * @param req 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     * @return 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    public VmsControlDto.VmsControlRes fileUpload(Long symbLibNmbr, VmsControlDto.VmsFileUploadReq req) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        byte[] aviData  = req.getAviData(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        String fileName = req.getSymbFileNm(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        VmsControlDto.VmsControlRes result = new VmsControlDto.VmsControlRes(0, "success"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        if (aviData.length > 0 && fileName != null) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            File file = new File(this.config.getFtpVideoDir() + fileName); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            if (file.exists()) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                file.delete(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            try (FileOutputStream fos = new FileOutputStream(file)) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                fos.write(aviData); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            catch (IOException ioException) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                result.setResult(7, "파일 업로드 중 파일생성에 실패하였습니다. (" + fileName + ")"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            result.setResult(9, "파일을 생성할수 없습니다. (" + fileName + ")"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        return result; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 |