mirror of
http://git.mhez-qa.uplus.co.kr/hubez/hubez-admin.git
synced 2025-12-06 19:09:49 +09:00
작업 중
This commit is contained in:
@@ -36,9 +36,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<input type="radio" v-model="state" name="state" value="use" id="popup_radio1">
|
<input type="radio" v-model="state" name="state" value="USE" id="popup_radio1">
|
||||||
<label for="popup_radio1" style="margin-right: 20px;">사용</label>
|
<label for="popup_radio1" style="margin-right: 20px;">사용</label>
|
||||||
<input type="radio" v-model="state" name="state" value="notUse" id="popup_radio2">
|
<input type="radio" v-model="state" name="state" value="NOTUSE" id="popup_radio2">
|
||||||
<label for="popup_radio2" style="margin-right: 30px;">점검중</label>
|
<label for="popup_radio2" style="margin-right: 30px;">점검중</label>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@@ -132,8 +132,10 @@ export default {
|
|||||||
fnSaveTxt(){
|
fnSaveTxt(){
|
||||||
let params = {
|
let params = {
|
||||||
startDate : moment(this.startDate).format('YYYY-MM-DD'),
|
startDate : moment(this.startDate).format('YYYY-MM-DD'),
|
||||||
startTime : this.startTime,
|
startTimeT : this.startTime.HH,
|
||||||
endTime : this.endTime,
|
startTimeM : this.startTime.mm,
|
||||||
|
endTimeT : this.endTime.HH,
|
||||||
|
endTimeM : this.endTime.mm,
|
||||||
state : this.state,
|
state : this.state,
|
||||||
}
|
}
|
||||||
sysMgtApi.setWorkState(params);
|
sysMgtApi.setWorkState(params);
|
||||||
|
|||||||
105
src/main/java/kr/co/uplus/ez/api/comm/FileServiceImpl.java
Normal file
105
src/main/java/kr/co/uplus/ez/api/comm/FileServiceImpl.java
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
package kr.co.uplus.ez.api.comm;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.core.io.UrlResource;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.FileSystemUtils;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import kr.co.uplus.ez.api.comm.FileService;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class FileServiceImpl implements FileService {
|
||||||
|
// @Value("${spring.servlet.multipart.location}")
|
||||||
|
private String uploadPath = "/efs/admin";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
try {
|
||||||
|
Files.createDirectories(Paths.get(uploadPath));
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException("폴더 생성 실패");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void store(MultipartFile file) {
|
||||||
|
try {
|
||||||
|
if (file.isEmpty()) {
|
||||||
|
throw new Exception("빈 파일입니다.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Path root = Paths.get(uploadPath);
|
||||||
|
|
||||||
|
if (!Files.exists(root)) {
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
try (InputStream inputStream = file.getInputStream()) {
|
||||||
|
Files.copy(inputStream, root.resolve(
|
||||||
|
file.getOriginalFilename()), StandardCopyOption.REPLACE_EXISTING
|
||||||
|
);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("파일을 저장할 수 없습니다. Error: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("파일을 저장할 수 없습니다. Error: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Stream<Path> loadAll() {
|
||||||
|
try {
|
||||||
|
Path root = Paths.get(uploadPath);
|
||||||
|
return Files.walk(root, 1).filter(path -> !path.equals(root));
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException("파일 읽기 실패", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Path load(String filename) {
|
||||||
|
return Paths.get(uploadPath).resolve(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Resource loadAsResource(String filename) {
|
||||||
|
try {
|
||||||
|
Path file = load(filename);
|
||||||
|
Resource resource = new UrlResource(file.toUri());
|
||||||
|
|
||||||
|
if (resource.exists() || resource.isReadable()) {
|
||||||
|
return resource;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("파일을 읽을 수 없습니다. : " + filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
throw new RuntimeException("파일을 읽을 수 없습니다. : " + filename, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteAll() {
|
||||||
|
FileSystemUtils.deleteRecursively(Paths.get(uploadPath).toFile());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteFile(String filename) {
|
||||||
|
FileSystemUtils.deleteRecursively(Paths.get(uploadPath + "\\" + filename).toFile());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -428,7 +428,7 @@ public class SysMgtController {
|
|||||||
|
|
||||||
@RequestMapping(value = "/setWorkState", method = {RequestMethod.POST})
|
@RequestMapping(value = "/setWorkState", method = {RequestMethod.POST})
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public SetWorkStateResDto setWorkState(@RequestBody @Valid Object setWorkParam, BindingResult bindingResult) {
|
public SetWorkStateResDto setWorkState(@RequestBody @Valid SetWorkStateReqDto setWorkParam, BindingResult bindingResult) {
|
||||||
|
|
||||||
if (validComponents.validParameter(bindingResult)) {
|
if (validComponents.validParameter(bindingResult)) {
|
||||||
return new SetWorkStateResDto(ApiResponseCode.CM_PARAMETER_ERROR);
|
return new SetWorkStateResDto(ApiResponseCode.CM_PARAMETER_ERROR);
|
||||||
|
|||||||
@@ -15,8 +15,13 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -39,6 +44,9 @@ public class SysMgtService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
FileService fileService;
|
FileService fileService;
|
||||||
|
|
||||||
|
// 파일위치
|
||||||
|
@Value("${hubeasy_file_info.work-location}") private String dirWorkState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* date : 2022. 4. 25.
|
* date : 2022. 4. 25.
|
||||||
* auth : ckr
|
* auth : ckr
|
||||||
@@ -530,12 +538,54 @@ public class SysMgtService {
|
|||||||
return new NotiListResDto(ApiResponseCode.SUCCESS, notiListRes);
|
return new NotiListResDto(ApiResponseCode.SUCCESS, notiListRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SetWorkStateResDto setWorkState(Object setWorkParam) {
|
|
||||||
|
|
||||||
|
public SetWorkStateResDto setWorkState(SetWorkStateReqDto setWorkParam) {
|
||||||
|
|
||||||
|
File file = new File("C:\\efs\\home\\workState\\workStatefile.txt");
|
||||||
|
|
||||||
|
String[] workParamArr = setWorkParam.getStartDate().split("-");
|
||||||
|
|
||||||
|
String year = "";
|
||||||
|
String month = "";
|
||||||
|
String day = "";
|
||||||
|
|
||||||
|
//1.파일 값 셋팅
|
||||||
|
String setWorkState = "";
|
||||||
|
|
||||||
|
setWorkState += setWorkParam.getState() + "@";
|
||||||
|
setWorkState += workParamArr[0] + "@";
|
||||||
|
setWorkState += workParamArr[1] + "@";
|
||||||
|
setWorkState += workParamArr[2] + "@";
|
||||||
|
setWorkState += setWorkParam.getStartTimeT() + "@";
|
||||||
|
setWorkState += setWorkParam.getStartTimeM() + "@";
|
||||||
|
setWorkState += setWorkParam.getEndTimeT() + "@";
|
||||||
|
setWorkState += setWorkParam.getEndTimeM();
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
//1. workState 파일이 없다면? 만들어라
|
||||||
|
if(!file.exists()) {
|
||||||
|
file.createNewFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
//2. Buffer를 사용해서 File에 write할 수 있는 BufferedWriter 생성
|
||||||
|
FileWriter fw = new FileWriter(file);
|
||||||
|
BufferedWriter writer = new BufferedWriter(fw);
|
||||||
|
|
||||||
|
logger.debug("setWorkString={}",setWorkState);
|
||||||
|
|
||||||
|
//3. 파일에 쓰기
|
||||||
|
writer.write(setWorkState);
|
||||||
|
|
||||||
|
//4. Buffer
|
||||||
|
writer.close();
|
||||||
|
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
logger.debug("setWorkParam={}",setWorkParam);
|
logger.debug("setWorkParam={}",setWorkParam);
|
||||||
|
|
||||||
|
|
||||||
return new SetWorkStateResDto(ApiResponseCode.SUCCESS);
|
return new SetWorkStateResDto(ApiResponseCode.SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package kr.co.uplus.ez.api.sysMgt.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SetWorkStateReqDto {
|
||||||
|
|
||||||
|
String startDate;
|
||||||
|
String startTimeT;
|
||||||
|
String startTimeM;
|
||||||
|
String endTimeT;
|
||||||
|
String endTimeM;
|
||||||
|
String state;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user