mirror of
http://git.mhez-qa.uplus.co.kr/hubez/hubez-admin.git
synced 2025-12-06 16:43:32 +09:00
서비스 점검 이력조회 back
This commit is contained in:
@@ -72,7 +72,7 @@ class CheckProcess implements Runnable {
|
||||
long maxMemory = runtime.maxMemory() / (1024 * 1024);
|
||||
long usedMemory = totalMemory - freeMemory;
|
||||
|
||||
log.info("{} Process Monitoring : maxMemory -> {}MB, totalMemory -> {}MB, usedMemory -> {}MB, freeMemory -> {}MB, ActiveThread -> {}",
|
||||
PROC_NAME, maxMemory, totalMemory, usedMemory, freeMemory, Thread.activeCount());
|
||||
// log.info("{} Process Monitoring : maxMemory -> {}MB, totalMemory -> {}MB, usedMemory -> {}MB, freeMemory -> {}MB, ActiveThread -> {}",
|
||||
// PROC_NAME, maxMemory, totalMemory, usedMemory, freeMemory, Thread.activeCount());
|
||||
}
|
||||
}
|
||||
@@ -436,4 +436,18 @@ public class SysMgtController {
|
||||
|
||||
return sysService.setWorkState(setWorkParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* data: 2023. 05.09.
|
||||
* auth: won
|
||||
* desc: 서비스 점검 이력 조회
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "svcCheckList", notes = "서비스 점검 이력 조회")
|
||||
@RequestMapping(value = "/svcCheckList", method = {RequestMethod.POST})
|
||||
@ResponseBody
|
||||
public SvcCheckListResDto svcCheckList(@RequestBody @Valid SvcCheckListReqDto svcCheckListReqDto) {
|
||||
return sysService.svcCheckLists(svcCheckListReqDto);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@ import kr.co.uplus.ez.api.comm.dto.BatchChkDto;
|
||||
import kr.co.uplus.ez.api.homeMgt.dto.NoticeListReqDto;
|
||||
import kr.co.uplus.ez.api.sysMgt.dto.*;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -56,4 +58,5 @@ public interface SysMgtMapper {
|
||||
public List<NotiList> notiListSelect(NotiListReqDto notiListReqDto);
|
||||
|
||||
int notiListSelectCnt(NotiListReqDto notiListReqDto);
|
||||
|
||||
}
|
||||
@@ -16,17 +16,26 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.UrlResource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SysMgtService {
|
||||
@@ -46,6 +55,9 @@ public class SysMgtService {
|
||||
|
||||
// 파일위치
|
||||
@Value("${hubeasy_file_info.work-location}") private String dirWorkState;
|
||||
|
||||
// @Value("${spring.servlet.multipart.location}")
|
||||
private String uploadPath = "/efs/admin";
|
||||
|
||||
/**
|
||||
* date : 2022. 4. 25.
|
||||
@@ -588,4 +600,136 @@ public class SysMgtService {
|
||||
logger.debug("setWorkParam={}",setWorkParam);
|
||||
return new SetWorkStateResDto(ApiResponseCode.SUCCESS);
|
||||
}
|
||||
|
||||
//파일 load
|
||||
public Path load(String filename) {
|
||||
return Paths.get(uploadPath).resolve(filename);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* data: 2023. 05.09.
|
||||
* auth: won
|
||||
* desc: 서비스 점검 이력 조회
|
||||
* @return
|
||||
*/
|
||||
public SvcCheckListResDto svcCheckLists(@Valid SvcCheckListReqDto svcCheckListReqDto) {
|
||||
SysMgtMapper sysmgtmapper = sqlSessionSlave.getMapper(SysMgtMapper.class);
|
||||
|
||||
String workStateData = "";
|
||||
log.debug("1번 ={}",workStateData);
|
||||
String [] workStateDataArr = new String[7];
|
||||
log.info("getWorkStateCheck START ==========================================");
|
||||
|
||||
//CheckList >= svcCheckList
|
||||
SvcCheckListRes svcCheckListRes = new SvcCheckListRes();
|
||||
List<SvcCheckList> CheckList = new ArrayList<>();
|
||||
SvcCheckList svcCheckList = new SvcCheckList();
|
||||
|
||||
String nowPage = String.valueOf(svcCheckListReqDto.getPage());
|
||||
int totalCnt = 0;
|
||||
// sysmgtmapper.svcCheckListSelectCnt(svcCheckListReqDto);
|
||||
|
||||
try {
|
||||
//파일 읽기
|
||||
Resource file = loadAsResource(dirWorkState);
|
||||
BufferedReader reader = new BufferedReader(new FileReader(file.getFile()));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
sb.append(line);
|
||||
}
|
||||
reader.close();
|
||||
|
||||
if(null != sb.toString() && !"".equals(sb.toString())) {
|
||||
workStateData = sb.toString();
|
||||
String[] Data = workStateData.split(",");
|
||||
|
||||
//항목 객체에 값 셋팅
|
||||
for (int i = 0; i < Data.length; i++) {
|
||||
workStateDataArr = Data[i].split("@");
|
||||
svcCheckList.setWorkState(workStateDataArr[0]);
|
||||
svcCheckList.setYear(workStateDataArr[1]);
|
||||
svcCheckList.setMonth(workStateDataArr[2]);
|
||||
svcCheckList.setDay(workStateDataArr[3]);
|
||||
svcCheckList.setStrtHour(workStateDataArr[4]);
|
||||
svcCheckList.setStrtMin(workStateDataArr[5]);
|
||||
svcCheckList.setEndHour(workStateDataArr[6]);
|
||||
svcCheckList.setEndMin(workStateDataArr[7]);
|
||||
|
||||
String Ymd = svcCheckList.getYear()+"-"+ svcCheckList.getMonth()+"-"+ svcCheckList.getDay();
|
||||
svcCheckList.setYmd(Ymd);
|
||||
String StrHd = svcCheckList.getStrtHour()+" : "+ svcCheckList.getStrtMin();
|
||||
svcCheckList.setStrHd(StrHd);
|
||||
String EndHd = svcCheckList.getEndHour()+" : "+ svcCheckList.getEndMin();
|
||||
svcCheckList.setEndHd(EndHd);
|
||||
log.debug("aa번 ={}",svcCheckList.getYmd());
|
||||
log.debug("aa번 ={}",svcCheckList.getStrHd());
|
||||
log.debug("aa번 ={}",svcCheckList.getEndHd());
|
||||
log.debug("2번 ={}",svcCheckList);
|
||||
|
||||
}
|
||||
// 리스트에 항목 추가
|
||||
CheckList.add(svcCheckList);
|
||||
log.debug("4번 ={}",CheckList.add(svcCheckList));
|
||||
totalCnt = Data.length;
|
||||
int page = svcCheckListReqDto.getPage();
|
||||
int pagePerRows = svcCheckListReqDto.getPagePerRows();
|
||||
page = (page - 1) * pagePerRows;
|
||||
svcCheckListReqDto.setPage(page);
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 파일 읽기 실패 시 "USE"로 설정하고 결과 반환
|
||||
log.error("WORK STATE READ FAIL : {}",e.getMessage(), e);
|
||||
svcCheckList.setWorkState("USE");
|
||||
log.debug("5번 ={}",svcCheckList.getWorkState());
|
||||
|
||||
String[] Data = workStateData.split(",");
|
||||
|
||||
totalCnt = Data.length;
|
||||
int page = svcCheckListReqDto.getPage();
|
||||
int pagePerRows = svcCheckListReqDto.getPagePerRows();
|
||||
page = (page - 1) * pagePerRows;
|
||||
svcCheckListReqDto.setPage(page);
|
||||
return new SvcCheckListResDto(ApiResponseCode.SUCCESS);
|
||||
}
|
||||
|
||||
if (totalCnt == 0) {
|
||||
svcCheckListRes.setList(new ArrayList<>());
|
||||
Paging paging = new Paging();
|
||||
paging.setPage(nowPage);
|
||||
paging.setTotalCnt(String.valueOf(totalCnt));
|
||||
svcCheckListRes.setPaging(paging);
|
||||
|
||||
return new SvcCheckListResDto(ApiResponseCode.CM_NOT_FOUND, svcCheckListRes);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// CheckList = sysmgtmapper.svcCheckListSelect(svcCheckListReqDto);
|
||||
svcCheckListRes.setList(CheckList);
|
||||
Paging paging = new Paging();
|
||||
paging.setPage(nowPage);
|
||||
paging.setTotalCnt(String.valueOf(totalCnt));
|
||||
svcCheckListRes.setPaging(paging);
|
||||
|
||||
return new SvcCheckListResDto(ApiResponseCode.SUCCESS,svcCheckListRes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package kr.co.uplus.ez.api.sysMgt.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Data
|
||||
public class SvcCheckList implements Serializable{
|
||||
|
||||
@ApiModelProperty(example = "상태변경", name = "상태변경", dataType = "String")
|
||||
private String workState;
|
||||
@ApiModelProperty(example = "년도", name = "년도", dataType = "String")
|
||||
private String year;
|
||||
@ApiModelProperty(example = "월", name = "월", dataType = "String")
|
||||
private String month;
|
||||
@ApiModelProperty(example = "날", name = "날", dataType = "String")
|
||||
private String day;
|
||||
@ApiModelProperty(example = "시작시각", name = "시작시각", dataType = "String")
|
||||
private String strtHour;
|
||||
@ApiModelProperty(example = "시작분", name = "시작분", dataType = "String")
|
||||
private String strtMin;
|
||||
@ApiModelProperty(example = "종료시각", name = "종료시각", dataType = "String")
|
||||
private String endHour;
|
||||
@ApiModelProperty(example = "종료분", name = "종료분", dataType = "String")
|
||||
private String endMin;
|
||||
@ApiModelProperty(example = "날짜", name = "날짜", dataType = "String")
|
||||
private String ymd;
|
||||
@ApiModelProperty(example = "시작시간", name = "시작시간", dataType = "String")
|
||||
private String strHd;
|
||||
@ApiModelProperty(example = "종료시간", name = "종료시간", dataType = "String")
|
||||
private String endHd;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package kr.co.uplus.ez.api.sysMgt.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Data
|
||||
public class SvcCheckListReqDto implements Serializable{
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty(example = "50", name = "페이지당 조회할 목록 수", dataType = "String")
|
||||
private int pagePerRows;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty(example = "1", name = "현재 페이지", dataType = "int")
|
||||
private int page;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package kr.co.uplus.ez.api.sysMgt.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import kr.co.uplus.ez.common.data.Paging;
|
||||
import lombok.Data;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Data
|
||||
public class SvcCheckListRes implements Serializable{
|
||||
|
||||
private Paging paging;
|
||||
private List<SvcCheckList> list;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package kr.co.uplus.ez.api.sysMgt.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import kr.co.uplus.ez.common.data.ApiResponseCode;
|
||||
import kr.co.uplus.ez.common.data.ResponseMessage;
|
||||
import lombok.Data;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Data
|
||||
public class SvcCheckListResDto extends ResponseMessage implements Serializable{
|
||||
|
||||
private SvcCheckListRes data;
|
||||
|
||||
public SvcCheckListResDto() {
|
||||
this.retCode = ApiResponseCode.SUCCESS.getResultCode();
|
||||
this.retMsg = ApiResponseCode.SUCCESS.getResultMsg();
|
||||
}
|
||||
|
||||
public SvcCheckListResDto(ApiResponseCode returnStr) {
|
||||
this.retCode = returnStr.getResultCode();
|
||||
this.retMsg = returnStr.getResultMsg();
|
||||
}
|
||||
|
||||
public SvcCheckListResDto(ApiResponseCode returnStr, SvcCheckListRes data) {
|
||||
this.retCode = returnStr.getResultCode();
|
||||
this.retMsg = returnStr.getResultMsg();
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user